andrey Thu, 29 Apr 2010 11:49:08 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=298767
Log:
Fix crash if OOM and USE_ZEND_ALLOC=0
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
2010-04-29 10:53:24 UTC (rev 298766)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
2010-04-29 11:49:08 UTC (rev 298767)
@@ -705,7 +705,7 @@
MYSQLND_PACKET_COMMAND *packet= (MYSQLND_PACKET_COMMAND *) _packet;
MYSQLND_NET *net = conn->net;
unsigned int error_reporting = EG(error_reporting);
- size_t written;
+ size_t written = 0;
DBG_ENTER("php_mysqlnd_cmd_write");
/*
@@ -734,6 +734,9 @@
size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE, ret;
zend_uchar *tmp, *p;
tmp = (tmp_len > net->cmd_buffer.length)?
mnd_emalloc(tmp_len):net->cmd_buffer.buffer;
+ if (!tmp) {
+ goto end;
+ }
p = tmp + MYSQLND_HEADER_SIZE; /* skip the header */
int1store(p, packet->command);
@@ -748,6 +751,7 @@
}
written = ret;
}
+end:
if (error_reporting) {
/* restore error reporting */
EG(error_reporting) = error_reporting;
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-04-29
10:53:24 UTC (rev 298766)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-04-29
11:49:08 UTC (rev 298767)
@@ -705,7 +705,7 @@
MYSQLND_PACKET_COMMAND *packet= (MYSQLND_PACKET_COMMAND *) _packet;
MYSQLND_NET *net = conn->net;
unsigned int error_reporting = EG(error_reporting);
- size_t written;
+ size_t written = 0;
DBG_ENTER("php_mysqlnd_cmd_write");
/*
@@ -734,6 +734,9 @@
size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE, ret;
zend_uchar *tmp, *p;
tmp = (tmp_len > net->cmd_buffer.length)?
mnd_emalloc(tmp_len):net->cmd_buffer.buffer;
+ if (!tmp) {
+ goto end;
+ }
p = tmp + MYSQLND_HEADER_SIZE; /* skip the header */
int1store(p, packet->command);
@@ -748,6 +751,7 @@
}
written = ret;
}
+end:
if (error_reporting) {
/* restore error reporting */
EG(error_reporting) = error_reporting;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php