[PATCH] PHP4 and GD, reproduceable SEGFAULT

From: Date: Wed, 19 Apr 2000 12:25:17 +0000
Subject: [PATCH] PHP4 and GD, reproduceable SEGFAULT
Groups: php.dev 
Request: Send a blank email to php-dev+get-18039@lists.php.net to get a copy of this message
Hello, With gd and jpeg enabled in PHP4b4. Here's a simple test script that crashes PHP4-cvs : <?php ImageCreateFromJPEG("/dev/null"); ImageCreateFromPNG("/dev/null"); ?> It crashes at shutdown time. I backtraced it to the following : (from gd.c, line 688) : im = gdImageCreateFromJpeg(fp); fflush(fp); fclose(fp); ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd)); } If gdImageCreateFromJpeg cannot interpret the file to create the image, it returns NULL. So, NULL is registered as a resource to free. Then, at shutdown time, 'gdImageDestroy' is called with NULL as argument, and it crashes. The patch I attach to this message does the folloing: 1) Issue a warning if gdImageCreateFromJPEG returns NULL, 2) Returns false to the script (so that the programmer can test it), 3) Prevents 'im' to be registered as a resource to destroy. The situation is exactly the same for PNG and GIF. Flavien Lebarbé. -- Flavien LEBARBE OPEN CARE Support for Freedom mailto:flebarbe@ocare.com http://www.ocare.com Tel:+33 141430890 Fax:+33 141430891

« previous php.dev (#18039) next »