summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-05-25 22:34:47 (GMT)
committerAndrey Hristov <andrey@php.net>2010-05-25 22:34:47 (GMT)
commitdecdfeeeb28e652ce01dbe02697e21ed4baf46fa (patch)
tree00886ff749ba5bccfbfdcb3ed9bb69c20ef6c969 /ext
parent844b43565591df45ba94310d5e104b2efe51da24 (diff)
downloadphp-decdfeeeb28e652ce01dbe02697e21ed4baf46fa.tar.gz
Access memory which was really allocated
Diffstat (limited to 'ext')
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 08d470c..af8a4a9 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -1908,8 +1908,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet)(MYSQLND_PROTOCOL * const prot
{
struct st_mysqlnd_packet_greet * packet = mnd_pecalloc(1, packet_methods[PROT_GREET_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_greet_packet");
- packet->header.m = &packet_methods[PROT_GREET_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_GREET_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1921,8 +1923,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet)(MYSQLND_PROTOCOL * const proto
{
struct st_mysqlnd_packet_auth * packet = mnd_pecalloc(1, packet_methods[PROT_AUTH_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_auth_packet");
- packet->header.m = &packet_methods[PROT_AUTH_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_AUTH_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1934,8 +1938,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_ok_packet)(MYSQLND_PROTOCOL * const protoco
{
struct st_mysqlnd_packet_ok * packet = mnd_pecalloc(1, packet_methods[PROT_OK_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_ok_packet");
- packet->header.m = &packet_methods[PROT_OK_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_OK_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1947,8 +1953,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_eof_packet)(MYSQLND_PROTOCOL * const protoc
{
struct st_mysqlnd_packet_eof * packet = mnd_pecalloc(1, packet_methods[PROT_EOF_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_eof_packet");
- packet->header.m = &packet_methods[PROT_EOF_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_EOF_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1960,8 +1968,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_command_packet)(MYSQLND_PROTOCOL * const pr
{
struct st_mysqlnd_packet_command * packet = mnd_pecalloc(1, packet_methods[PROT_CMD_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_command_packet");
- packet->header.m = &packet_methods[PROT_CMD_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_CMD_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1973,8 +1983,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_rset_header_packet)(MYSQLND_PROTOCOL * cons
{
struct st_mysqlnd_packet_rset_header * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_HEADER_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_rset_header_packet");
- packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1986,8 +1998,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_result_field_packet)(MYSQLND_PROTOCOL * con
{
struct st_mysqlnd_packet_res_field * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_FLD_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_result_field_packet");
- packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -1999,8 +2013,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_row_packet)(MYSQLND_PROTOCOL * const protoc
{
struct st_mysqlnd_packet_row * packet = mnd_pecalloc(1, packet_methods[PROT_ROW_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_row_packet");
- packet->header.m = &packet_methods[PROT_ROW_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_ROW_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -2012,8 +2028,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_stats_packet)(MYSQLND_PROTOCOL * const prot
{
struct st_mysqlnd_packet_stats * packet = mnd_pecalloc(1, packet_methods[PROT_STATS_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_stats_packet");
- packet->header.m = &packet_methods[PROT_STATS_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_STATS_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -2025,8 +2043,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_prepare_response_packet)(MYSQLND_PROTOCOL *
{
struct st_mysqlnd_packet_prepare_response * packet = mnd_pecalloc(1, packet_methods[PROT_PREPARE_RESP_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_prepare_response_packet");
- packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -2038,8 +2058,10 @@ MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet)(MYSQLND_PROTOC
{
struct st_mysqlnd_packet_chg_user_resp * packet = mnd_pecalloc(1, packet_methods[PROT_CHG_USER_RESP_PACKET].struct_size, persistent);
DBG_ENTER("mysqlnd_protocol::get_change_user_response_packet");
- packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
- packet->header.persistent = persistent;
+ if (packet) {
+ packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
+ packet->header.persistent = persistent;
+ }
DBG_RETURN(packet);
}
/* }}} */
@@ -2070,9 +2092,10 @@ mysqlnd_protocol_init(zend_bool persistent TSRMLS_DC)
DBG_ENTER("mysqlnd_protocol_init");
DBG_INF_FMT("persistent=%d", persistent);
- ret->persistent = persistent;
-
- ret->m = mysqlnd_mysqlnd_protocol_methods;
+ if (ret) {
+ ret->persistent = persistent;
+ ret->m = mysqlnd_mysqlnd_protocol_methods;
+ }
DBG_RETURN(ret);
}