[Scummvm-git-logs] scummvm master -> 387dd08f5dec09befddf6ae60e52b829ab54ba53
dreammaster
noreply at scummvm.org
Wed Dec 14 04:04:03 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
387dd08f5d GLK: SCOTT: Fix leak in disk_image.cpp
Commit: 387dd08f5dec09befddf6ae60e52b829ab54ba53
https://github.com/scummvm/scummvm/commit/387dd08f5dec09befddf6ae60e52b829ab54ba53
Author: angstsmurf (ignalina at me.com)
Date: 2022-12-13T20:03:58-08:00
Commit Message:
GLK: SCOTT: Fix leak in disk_image.cpp
The method diCreateFromData() is set up as if it is going to copy the
data supplied by the caller to the _image member, allocating memory for
it, but then just assigns the data to it instead, leaking the allocated
memory.
This also means that if the data supplied is not a valid disk image, it
will delete the original data in the default case.
We fix this by just removing the allocation and the deletion. An
alternative would have been to actually copy the data instead.
Changed paths:
engines/glk/scott/disk_image.cpp
diff --git a/engines/glk/scott/disk_image.cpp b/engines/glk/scott/disk_image.cpp
index 389f105bb5a..1b30adb2db4 100644
--- a/engines/glk/scott/disk_image.cpp
+++ b/engines/glk/scott/disk_image.cpp
@@ -744,18 +744,14 @@ RawDirEntry *findLargestFileEntry(DiskImage *di) {
DiskImage *diCreateFromData(uint8_t *data, int length) {
DiskImage *di;
+ if (data == nullptr)
+ return nullptr;
+
if ((di = new DiskImage) == nullptr) {
return nullptr;
}
di->_size = length;
-
- /* allocate buffer for image */
- if ((di->_image = new byte[length]) == nullptr) {
- delete di;
- return nullptr;
- }
-
di->_image = data;
di->_errinfo = nullptr;
@@ -798,7 +794,6 @@ DiskImage *diCreateFromData(uint8_t *data, int length) {
break;
default:
- delete[] di->_image;
delete di;
return nullptr;
}
More information about the Scummvm-git-logs
mailing list