gd_compat.c 522 B

12345678910111213141516171819202122
  1. #ifdef HAVE_CONFIG_H
  2. #include "config.h"
  3. #else
  4. #include "php_config.h"
  5. #endif
  6. #include "gd_compat.h"
  7. #include "php.h"
  8. int overflow2(int a, int b)
  9. {
  10. if(a <= 0 || b <= 0) {
  11. php_error_docref(NULL, E_WARNING, "One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
  12. return 1;
  13. }
  14. if(a > INT_MAX / b) {
  15. php_error_docref(NULL, E_WARNING, "Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
  16. return 1;
  17. }
  18. return 0;
  19. }