From: Marcus Boerger Date: Sat, 30 Mar 2002 18:31:08 +0000 (+0000) Subject: -memory leaks X-Git-Tag: php-4.2.0RC2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f9001850e5535d9f8a72cc9cf97aa96b5dd41ae;p=php -memory leaks --- diff --git a/ext/exif/exif.c b/ext/exif/exif.c index a0d95a9dd4..ed283f7b10 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -777,7 +777,7 @@ void exif_add_image_info( image_info_type *image_info, int section_index, char * 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 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo, FILE *infile) 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 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo, FILE *infile) 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 php_exif_discard_sections(image_info_type *ImageInfo) int a; if ( ImageInfo->sections_count) { - for (a=0;asections_count-1;a++) { + for (a=0;asections_count;a++) { efree(ImageInfo->sections[a].Data); } } @@ -2092,6 +2091,7 @@ int php_exif_discard_imageinfo(image_info_type *ImageInfo) if (ImageInfo->FileName) efree(ImageInfo->FileName); if (ImageInfo->Thumbnail) efree(ImageInfo->Thumbnail); + if (ImageInfo->UserComment) efree(ImageInfo->UserComment); for (i=0; i