imagecreatefromstring() crashes PHP script

Issue #116 on hold
Former user created an issue

libgd crashes my PHP script on certain images using the imagecreatefromstring. This happens only on Linux and not on Windows. My GD and PHP details are below with an image and code to reproduce.

PHP Version 5.3.23 (and on 5.3.27) GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 6b PNG Support enabled libPNG Version 1.2.10 WBMP Support enabled XPM Support enabled libXpm Version 30411 XBM Support enabled

error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors","on");

if ($handle = opendir('./images/')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
            getThumbnail('./images/' . $entry);
        }
    }
    closedir($handle);
}

function getThumbnail($filename) {
    $sourceImage = @imagecreatefromstring(@file_get_contents($filename));
}

echo 'we made it';

Comments (2)

  1. Pierre Joye

    hi,

    Thanks for the report!

    Please try using a more recent PHP version.

    If it still happens please provide the image crashing php.

    Thanks,

  2. Log in to comment