Skip to content

Commit 5406ec6

Browse files
committed
This patch just cleans up some memory and file handles in the error
cases of ldverify. The initial memory leak was rsound and exposed by cppcheck [Oliver Stoeneberg]
1 parent 788c7e6 commit 5406ec6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/tools/ldverify.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ int main(int argc, char *argv[])
717717
bitmap = bitmap_alloc(info.width, info.height, BITMAP_FORMAT_YUY16);
718718
if (bitmap == NULL)
719719
{
720+
isavi ? close_avi(file) : close_chd(file);
720721
fprintf(stderr, "Out of memory creating %dx%d bitmap\n", info.width, info.height);
721722
return 1;
722723
}
@@ -726,6 +727,12 @@ int main(int argc, char *argv[])
726727
rsound = malloc(info.samplerate * sizeof(*rsound));
727728
if (lsound == NULL || rsound == NULL)
728729
{
730+
isavi ? close_avi(file) : close_chd(file);
731+
bitmap_free(bitmap);
732+
if (rsound != NULL)
733+
free(rsound);
734+
if (lsound != NULL)
735+
free(lsound);
729736
fprintf(stderr, "Out of memory allocating sound buffers of %d bytes\n", (INT32)(info.samplerate * sizeof(*rsound)));
730737
return 1;
731738
}

0 commit comments

Comments
 (0)