Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.3

Bug #8856 Broken error handling in image() function
Submitted: 2006-10-05 04:08 UTC Modified: 2006-12-17 10:57 UTC
From: mattias at thorslund dot us Assigned: yunosh
Status: Closed Package: File_PDF (version 0.1.0)
PHP Version: 4.4.0 OS: Linux/Mandriva 2006.0
Roadmaps: (Not assigned)    
Subscription  


 [2006-10-05 04:08 UTC] mattias at thorslund dot us (Mattias Thorslund)
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

Comments

 [2006-10-05 07:02 UTC] yunosh (Jan Schneider)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.