imageloadfont_invalid.phpt 810 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. imageloadfont() function crashes
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('gd')) die("skip gd extension not available\n");
  6. ?>
  7. --FILE--
  8. <?php
  9. $filename = dirname(__FILE__) . '/font.gdf';
  10. $bin = "\x41\x41\x41\x41\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00";
  11. $fp = fopen($filename, 'wb');
  12. fwrite($fp, $bin);
  13. fclose($fp);
  14. $image = imagecreatetruecolor(50, 20);
  15. $font = imageloadfont($filename);
  16. $black = imagecolorallocate($image, 0, 0, 0);
  17. imagestring($image, $font, 0, 0, "Hello", $black);
  18. unlink($filename);
  19. ?>
  20. --EXPECTF--
  21. Warning: imageloadfont(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
  22. in %simageloadfont_invalid.php on line %d
  23. Warning: imageloadfont(): Error reading font, invalid font header in %simageloadfont_invalid.php on line %d