github_bug_215.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Github #215 (imagefilltoborder stack overflow when invalid pallete index used)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("gd")) die("skip GD not present");
  6. if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.2', '<')) {
  7. die("skip test requires GD 2.2.2 or higher");
  8. }
  9. ?>
  10. --FILE--
  11. <?php
  12. $image = imagecreate( 10, 10 );
  13. $bgd = imagecolorallocate( $image, 0, 0, 0 );
  14. $border = imagecolorallocate( $image, 255, 0, 0 );
  15. $fillcolor = imagecolorallocate( $image, 255, 0, 0 );
  16. /* Use unallocated color index */
  17. imagefilltoborder( $image, 0,0, $border+10, $fillcolor);
  18. echo "#1 passes\n";
  19. /* Use negative color index */
  20. imagefilltoborder( $image, 0,0, -$border, $fillcolor);
  21. echo "#2 passes\n";
  22. /* Use unallocated color index */
  23. imagefilltoborder( $image, 0,0, $border, $fillcolor+10);
  24. echo "#3 passes\n";
  25. /* Use negative color index */
  26. imagefilltoborder( $image, 0,0, $border, -$fillcolor);
  27. echo "#4 passes\n";
  28. /* Use negative color index */
  29. imagefilltoborder( $image, 0,0, $border+10, $fillcolor+10);
  30. echo "#5 passes";
  31. ?>
  32. --EXPECT--
  33. #1 passes
  34. #2 passes
  35. #3 passes
  36. #4 passes
  37. #5 passes