php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77989 Enhance imagebmp function if it's failed to output image
Submitted: 2019-05-08 03:45 UTC Modified: 2019-05-08 06:27 UTC
From: peter279k at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 7.3.5 OS: Ubuntu 18.04 LTS
Private report: No CVE-ID: None
 [2019-05-08 03:45 UTC] peter279k at gmail dot com
Description:
------------
According to the caution message in imagebmp function usage https://php.net/manual/en/function.imagebmp.php, it looks like the imagebmp should return false if it's failed to output the image.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-08 04:18 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2019-05-08 04:18 UTC] requinix@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2019-05-08 04:18 UTC] requinix@php.net
Oops, I meant


Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2019-05-08 06:20 UTC] peter279k at gmail dot com
-Status: Feedback +Status: Open
 [2019-05-08 06:20 UTC] peter279k at gmail dot com
Test script:
---------------
<?php
$im = imagecreatefrombmp('./php.bmp');

// Save the image
var_dump(imagebmp($im, './php.bmp'));

// Free up memory
imagedestroy($im);


Expected result:
----------------
PHP Warning:  imagecreatefrombmp(): './php.bmp' is not a valid BMP file in /root/bmp.php on line 3
PHP Warning:  imagebmp() expects parameter 1 to be resource, bool given in /root/bmp.php on line 6
bool(false)
PHP Warning:  imagedestroy() expects parameter 1 to be resource, bool given in /root/bmp.php on line 9

Actual result:
--------------
An error as follows:

PHP Warning:  imagecreatefrombmp(): './php.bmp' is not a valid BMP file in /root/bmp.php on line 3
PHP Warning:  imagebmp() expects parameter 1 to be resource, bool given in /root/bmp.php on line 6
NULL
PHP Warning:  imagedestroy() expects parameter 1 to be resource, bool given in /root/bmp.php on line 9
 [2019-05-08 06:27 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-05-08 06:27 UTC] requinix@php.net
https://www.php.net/manual/en/functions.internal.php
> Note: If the parameters given to a function are not what it expects, such as passing an array where a string is
> expected, the return value of the function is undefined. In this case it will likely return NULL but this is just
> a convention, and cannot be relied upon.

imagecreatefrombmp() failed. imagebmp() is returning NULL because the $im argument is invalid.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC