Date: 04/19/00
- Next message: Flavien LEBARBE: "[PHP-DEV] PHP history question : case sensitivity"
- Previous message: Ed Blincoe: "[PHP-DEV] pg_connect problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected> http://www.ocare.com Tel:+33 141430890 Fax:+33 141430891
--- gd.c.orig Wed Apr 19 12:27:40 2000 +++ gd.c Wed Apr 19 14:00:48 2000 @@ -460,6 +460,10 @@ fflush(fp); fclose(fp); + if (!im) { + php_error(E_WARNING,"ImageCreateFromPng: %s is not a valid PNG file", fn); + RETURN_FALSE; + } ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd)); } /* }}} */ @@ -570,6 +574,10 @@ fflush(fp); fclose(fp); + if (!im) { + php_error(E_WARNING,"ImageCreateFromGif: %s is not a recognized GIF file", fn); + RETURN_FALSE; + } ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd)); } /* }}} */ @@ -683,6 +691,10 @@ fflush(fp); fclose(fp); + if (!im) { + php_error(E_WARNING,"ImageCreateFromJPEG: %s is not a recognized JPEG file", fn); + RETURN_FALSE; + } ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd)); } /* }}} */
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Flavien LEBARBE: "[PHP-DEV] PHP history question : case sensitivity"
- Previous message: Ed Blincoe: "[PHP-DEV] pg_connect problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

