cvs: php4(PHP_4_2_0) /ext/exif exif.c

From: Date: Sat, 30 Mar 2002 18:31:08 +0000
Subject: cvs: php4(PHP_4_2_0) /ext/exif exif.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10785@lists.php.net to get a copy of this message
helly Sat Mar 30 13:31:08 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4/ext/exif exif.c Log: -memory leaks Index: php4/ext/exif/exif.c diff -u php4/ext/exif/exif.c:1.52.2.2 php4/ext/exif/exif.c:1.52.2.3 --- php4/ext/exif/exif.c:1.52.2.2 Sat Mar 16 15:02:12 2002 +++ php4/ext/exif/exif.c Sat Mar 30 13:31:08 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.52.2.2 2002/03/16 20:02:12 helly Exp $ */ +/* $Id: exif.c,v 1.52.2.3 2002/03/30 18:31:08 helly Exp $ */ /* ToDos * @@ -777,7 +777,7 @@ if ( !info_value->value.s) { info_value->length = 0; php_error(E_WARNING, "Could not allocate memory for thumbnail"); - return; + break; /* better return with "" instead of possible casing problems */ } break; @@ -1732,7 +1732,7 @@ ImageInfo->sections[ImageInfo->sections_count].Size = itemlen; Data = (uchar *)emalloc(itemlen+1); /* Add 1 to allow sticking a 0 at the end. */ - ImageInfo->sections[ImageInfo->sections_count].Data = Data; + ImageInfo->sections[ImageInfo->sections_count++].Data = Data; /* Store first two pre-read bytes. */ Data[0] = (uchar)lh; @@ -1743,7 +1743,6 @@ php_error(E_WARNING, "error reading from file: got=x%04X(=%d) != itemlen-2=x%04X(=%d)",got, got, itemlen-2, itemlen-2); return FALSE; } - ImageInfo->sections_count += 1; #ifdef EXIF_DEBUG php_error(E_NOTICE,"process section(x%02X=%s) @ x%04X + x%04X(=%d)", marker, exif_get_markername(marker), fpos, itemlen, itemlen); @@ -2074,7 +2073,7 @@ int a; if ( ImageInfo->sections_count) { - for (a=0;a<ImageInfo->sections_count-1;a++) { + for (a=0;a<ImageInfo->sections_count;a++) { efree(ImageInfo->sections[a].Data); } } @@ -2092,6 +2091,7 @@ if (ImageInfo->FileName) efree(ImageInfo->FileName); if (ImageInfo->Thumbnail) efree(ImageInfo->Thumbnail); + if (ImageInfo->UserComment) efree(ImageInfo->UserComment); for (i=0; i<SECTION_COUNT; i++) { exif_free_image_info( ImageInfo, i); } @@ -2217,8 +2217,10 @@ ImageInfo.sections_found |= FOUND_COMPUTED;/* do not inform about in debug*/ - if (ret==FALSE || array_init(return_value) == FAILURE || (sections_needed && !(sections_needed&ImageInfo.sections_found))) { + if (ret==FALSE || (sections_needed && !(sections_needed&ImageInfo.sections_found)) || array_init(return_value) == FAILURE) { + /* array_init must be checked at last! otherwise the array must be freed if a later test fails. */ php_exif_discard_imageinfo(&ImageInfo); + if ( sections_str) efree( sections_str); RETURN_FALSE; }

« previous php.cvs (#10785) next »