github_bug_215.phpt 1.0 KB

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