php-src/ext/gd/gd_compat.c
Arnaud Le Blanc 11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00

23 lines
522 B
C

#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#include <php_config.h>
#endif
#include "gd_compat.h"
#include "php.h"
int overflow2(int a, int b)
{
if(a <= 0 || b <= 0) {
php_error_docref(NULL, E_WARNING, "One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
return 1;
}
if(a > INT_MAX / b) {
php_error_docref(NULL, E_WARNING, "Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
return 1;
}
return 0;
}