PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » File_PDF » Bug #8856

Broken error handling in image() function

Details

Submitted2006-10-05 09:08 UTC
Frommattias at thorslund dot us
Assignedyunosh
StatusClosed
PackageFile_PDF
PHP Version4.4.0
OSLinux/Mandriva 2006.0
Roadmaps(Not assigned)

Comments

[2006-10-05 09:08 UTC] mattias at thorslund dot us

Description:
------------
I found a problem with how errors are handled in the image() function. If the _parsePNG() call on line 2193 in PDF.php returns an error, the $info object will be an error object, and can therefore not be used as an array a few lines down:

//this returns "Cannot use a scalar value as an array"
//when $info is a PEAR_Error object
$info['i'] = count($this->_images) + 1;

One solution might be to immediately check the value returned by _parsePNG(), and immediately return the error:

if(PEAR::IsError($info)){
return $info;
}

Test script:
---------------
Call image() and supply for instance a PNG image with an alpha channel.

Expected result:
----------------
Would have expected the error raised by _parsePNG() to propagate back as the image() return value?

Actual result:
--------------
File /var/www/s2a/pear/File/PDF.php, line 2198:
Cannot use a scalar value as an array

File /var/www/s2a/pear/File/PDF.php, line 2217:
Division by zero