diff --git a/configure.ac b/configure.ac index e18e1de2efb..4a59831cc26 100644 --- a/configure.ac +++ b/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 + 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) diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 0aee0d9b94b..20b82ac6582 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -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