mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add check for variable size array feature
Usage of VLA is not portable, wile supported by some compilers. For instance, GCC supports it even if -std=c89 is passed. Even if we would switch to C99, it would be still not portable at least with VC++. Thus, adding a centralized check so such code can be guarded and moved to alloca() if needed.
This commit is contained in:
14
configure.ac
14
configure.ac
@@ -784,6 +784,20 @@ if test "$ac_cv__asm_goto" = yes; then
|
||||
AC_DEFINE(HAVE_ASM_GOTO,1,[Define if asm goto support])
|
||||
fi
|
||||
|
||||
dnl Check for variable length array support
|
||||
AC_CACHE_CHECK([whether compiler supports VLA], ac_cv__compiler_c99_vla,
|
||||
[AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
int main(void) {
|
||||
int i[rand()%10];
|
||||
return 0;
|
||||
}
|
||||
],ac_cv__compiler_c99_vla=yes, ac_cv__compiler_c99_vla=no, ac_cv__compiler_c99_vla=no)])
|
||||
|
||||
if test "$ac_cv__compiler_c99_vla" = yes; then
|
||||
AC_DEFINE(HAVE_COMPILER_C99_VLA, 1, [Compiler supports VLA])
|
||||
fi
|
||||
|
||||
dnl Check valgrind support
|
||||
PHP_ARG_WITH(valgrind, [whether to enable valgrind support],
|
||||
[ --with-valgrind=DIR Enable valgrind support], yes, no)
|
||||
|
||||
@@ -2162,7 +2162,7 @@ size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _pa
|
||||
MYSQLND_PFC * pfc = conn->protocol_frame_codec;
|
||||
MYSQLND_VIO * vio = conn->vio;
|
||||
MYSQLND_STATS * stats = conn->stats;
|
||||
#ifndef _MSC_VER
|
||||
#if HAVE_COMPILER_C99_VLA
|
||||
zend_uchar buffer[MYSQLND_HEADER_SIZE + packet->password_len + 1];
|
||||
#else
|
||||
ALLOCA_FLAG(use_heap)
|
||||
@@ -2180,7 +2180,7 @@ size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _pa
|
||||
sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if !HAVE_COMPILER_C99_VLA
|
||||
free_alloca(buffer, use_heap);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user