com php-src: Merge remote-tracking branch 'origin/master' into str_size_and_int64: ext/mysqlnd/mysqlnd_ps_co dec.c

From: Date: Mon, 13 Jan 2014 11:29:30 +0000
Subject: com php-src: Merge remote-tracking branch 'origin/master' into str_size_and_int64: ext/mysqlnd/mysqlnd_ps_co dec.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75583@lists.php.net to get a copy of this message
Commit: 21643019c077e7530ed6cc6186e7bb8dc5a488ce Author: Anatol Belski <ab@php.net> Mon, 13 Jan 2014 12:29:30 +0100 Parents: bd5a5e7f7afec62a241853990c7d094d87d30df8 cf9966671cff5dd8ed1bade250aac3a48de23893 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=21643019c077e7530ed6cc6186e7bb8dc5a488ce Log: Merge remote-tracking branch 'origin/master' into str_size_and_int64 Conflicts: ext/mysqlnd/mysqlnd_ps_codec.c Changed paths: MM ext/mysqlnd/mysqlnd_ps_codec.c Diff: diff --cc ext/mysqlnd/mysqlnd_ps_codec.c index 2babd31,d8f3cda..665d7e2 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@@ -516,14 -516,41 +516,41 @@@ mysqlnd_stmt_copy_it(zval *** copies, z /* }}} */ + /* {{{ mysqlnd_stmt_execute_check_n_enlarge_buffer */ + static enum_func_status + mysqlnd_stmt_execute_check_n_enlarge_buffer(zend_uchar **buf, zend_uchar **p, size_t * buf_len, zend_uchar * const provided_buffer, size_t needed_bytes TSRMLS_DC) + { + const size_t overalloc = 5; + size_t left = (*buf_len - (*p - *buf)); + + if (left < (needed_bytes + overalloc)) { - size_t offset = *p - *buf; ++ ptrdiff_t offset = *p - *buf; + zend_uchar *tmp_buf; + *buf_len = offset + needed_bytes + overalloc; + tmp_buf = mnd_emalloc(*buf_len); + if (!tmp_buf) { + return FAIL; + } + memcpy(tmp_buf, *buf, offset); + if (*buf != provided_buffer) { + mnd_efree(*buf); + } + *buf = tmp_buf; + /* Update our pos pointer */ + *p = *buf + offset; + } + return PASS; + } + /* }}} */ + + /* {{{ mysqlnd_stmt_execute_store_params */ static enum_func_status - mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar **p, size_t *buf_len TSRMLS_DC) + mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar **p, size_t * buf_len TSRMLS_DC) { MYSQLND_STMT_DATA * stmt = s->data; - unsigned int i = 0; + php_uint_t i = 0; zend_uchar * provided_buffer = *buf; - size_t left = (*buf_len - (*p - *buf)); size_t data_size = 0; zval **copies = NULL;/* if there are different types */ enum_func_status ret = FAIL; @@@ -533,25 -560,10 +560,10 @@@ DBG_ENTER("mysqlnd_stmt_execute_store_params"); { - unsigned int null_count = (stmt->param_count + 7) / 8; + php_uint_t null_count = (stmt->param_count + 7) / 8; - /* give it some reserved space - 20 bytes */ - if (left < (null_count + 20)) { - ptrdiff_t offset = *p - *buf; - zend_uchar *tmp_buf; - *buf_len = offset + null_count + 20; - tmp_buf = mnd_emalloc(*buf_len); - if (!tmp_buf) { - SET_OOM_ERROR(*stmt->error_info); - goto end; - } - memcpy(tmp_buf, *buf, offset); - if (*buf != provided_buffer) { - mnd_efree(*buf); - } - *buf = tmp_buf; - - /* Update our pos pointer */ - *p = *buf + offset; + if (FAIL == mysqlnd_stmt_execute_check_n_enlarge_buffer(buf, p, buf_len, provided_buffer, null_count TSRMLS_CC)) { + SET_OOM_ERROR(*stmt->error_info); + goto end; } /* put null bytes */ null_byte_offset = *p - *buf;

« previous php.cvs (#75583) next »