gd2: fix double free when processing invalid headers

This closes #208.
master
Mike Frysinger 2016-04-30 21:55:17 -04:00
parent 0315e441ec
commit 658f168874
4 changed files with 7 additions and 2 deletions

View File

@ -359,9 +359,8 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
im =
_gd2CreateFromFile (in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy,
&chunkIdx);
if (im == NULL) {
gdFree (chunkIdx);
/* No need to free chunkIdx as _gd2CreateFromFile does it for us. */
return 0;
}

View File

@ -4,6 +4,8 @@ libgd_helper_programs += \
libgd_test_programs += \
gd2/gd2_empty_file
TESTS += \
gd2/invalid_header.sh
if HAVE_LIBZ
libgd_test_programs += \

Binary file not shown.

4
tests/gd2/invalid_header.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh -x
base=${0%.sh}
input="${base}.gd2"
exec ./gd2/gd2_read_corrupt "${input}"