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