Skip to content

Commit 138fd5b

Browse files
committed
Replace reallocarray with safe_perealloc
Fixes GH-9581
1 parent acccb39 commit 138fd5b

File tree

4 files changed

+3
-50
lines changed

4 files changed

+3
-50
lines changed

configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ if test "$ac_cv_func_getaddrinfo" = yes; then
691691
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
692692
fi
693693

694-
AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt reallocarray)
694+
AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
695695
AC_FUNC_ALLOCA
696696
PHP_TIME_R_TYPE
697697
PHP_CHECK_IN_ADDR_T
@@ -1618,7 +1618,7 @@ PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c \
16181618
php_ini_builder.c \
16191619
php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
16201620
strlcat.c explicit_bzero.c reentrancy.c php_variables.c php_ticks.c \
1621-
network.c php_open_temporary_file.c php_odbc_utils.c safe_bcmp.c reallocarray.c \
1621+
network.c php_open_temporary_file.c php_odbc_utils.c safe_bcmp.c \
16221622
output.c getopt.c php_syslog.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
16231623

16241624
PHP_ADD_SOURCES_X(main, fastcgi.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_FASTCGI_OBJS, no)

main/php.h

-8
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ END_EXTERN_C()
179179
#define explicit_bzero php_explicit_bzero
180180
#endif
181181

182-
#ifndef HAVE_REALLOCARRAY
183-
BEGIN_EXTERN_C()
184-
PHPAPI void* php_reallocarray(void *p, size_t nmb, size_t siz);
185-
END_EXTERN_C()
186-
#undef reallocarray
187-
#define reallocarray php_reallocarray
188-
#endif
189-
190182
BEGIN_EXTERN_C()
191183
PHPAPI int php_safe_bcmp(const zend_string *a, const zend_string *b);
192184
END_EXTERN_C()

main/reallocarray.c

-39
This file was deleted.

sapi/fpm/fpm/fpm_arrays.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static inline void *fpm_array_push(struct fpm_array_s *a) /* {{{ */
8686

8787
if (a->used == a->allocated) {
8888
size_t new_allocated = a->allocated ? a->allocated * 2 : 20;
89-
void *new_ptr = reallocarray(a->data, a->sz, new_allocated);
89+
void *new_ptr = safe_perealloc(a->data, a->sz, new_allocated, 0, true);
9090

9191
if (!new_ptr) {
9292
return 0;

0 commit comments

Comments
 (0)