]> granicus.if.org Git - php/commitdiff
Fix for sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE
authorvanviegen <github@vanviegen.net>
Wed, 21 Dec 2016 15:18:14 +0000 (16:18 +0100)
committerJoe Watkins <krakjoe@php.net>
Mon, 2 Jan 2017 14:56:41 +0000 (14:56 +0000)
Fixes bug #73800

news entry for PR #2249

NEWS
ext/mysqlnd/mysqlnd_wireprotocol.c

diff --git a/NEWS b/NEWS
index 9693b39b75c0017ddefc554f5ccedf1bbb50719f..020bcc04e059341d9cd8b12580317981cd43dd58 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,8 @@ PHP                                                                        NEWS
 - Mysqlnd:
   . Optimized handling of BIT fields - less memory copies and lower memory
     usage. (Andrey)
+  . Fixed bug #73800 (sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE). 
+       (vanviegen)
 
 - Opcache:
   . Fixed bug #73789 (Strange behavior of class constants in switch/case block).
index 03fcad987717aa197903ae5d21ff5aa65b352b05..b057a44e8276f51411d02ac716de3ba37b1ec2a3 100644 (file)
@@ -1477,7 +1477,12 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
          zero-length byte, don't read the body, there is no such.
        */
 
-       *data_size = 0;
+       /*
+         We're allocating an extra byte, as php_mysqlnd_rowp_read_text_protocol_aux
+         needs to be able to append a terminating \0 for atoi/atof.
+       */
+       *data_size = 1;
+       
        while (1) {
                if (FAIL == mysqlnd_read_header(pfc, vio, &header, stats, error_info)) {
                        ret = FAIL;
@@ -1526,6 +1531,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
                pool->free_chunk(pool, *buffer);
                *buffer = NULL;
        }
+       *data_size--;
        DBG_RETURN(ret);
 }
 /* }}} */