com php-src: Move code out, that handles the actual structure to be used for the decoded data. Will make it easier to add different structures:
ext/mysqlnd/mysqlnd_ps.c ext/mysqlnd/mysqlnd_result.c
| From: | Andrey Hristov | Date: | Mon, 17 Feb 2014 16:37:08 +0000 |
| Subject: | com php-src: Move code out, that handles the actual structure to be used for the decoded data. Will make it easier to add different structures: ext/mysqlnd/mysqlnd_ps.c ext/mysqlnd/mysqlnd_result.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76046@lists.php.net to get a copy of this message | ||
Commit: b2cd56c3cb9e752e3d0e4accb99d0f2e1ac71632
Author: Andrey Hristov <andrey@php.net> Mon, 17 Feb 2014 18:37:08 +0200
Parents: 0bc96ef3cc8aedee17d3ab389ee37e90d2ce4d20
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b2cd56c3cb9e752e3d0e4accb99d0f2e1ac71632
Log:
Move code out, that handles the actual structure to be used for the decoded
data. Will make it easier to add different structures
Changed paths:
M ext/mysqlnd/mysqlnd_ps..c
M ext/mysqlnd/mysqlnd_result.c
Diff:
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index 8096cbb..fa2abc7 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -104,6 +104,26 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s TSRMLS_DC)
ret = result->m.store_result_fetch_data(conn, result, result->meta, TRUE TSRMLS_CC);
if (PASS == ret) {
+ /* Overflow ? */
+ MYSQLND_RES_BUFFERED * set = result->stored_data;
+ if (set->row_count) {
+ /* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have
narrower range than uint64_t */
+ if (set->row_count * result->meta->field_count * sizeof(zval *) > SIZE_MAX) {
+ SET_OOM_ERROR(*conn->error_info);
+ DBG_RETURN(NULL);
+ }
+ /* if pecalloc is used valgrind barks gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch
revision 135036] (SUSE Linux) */
+ set->data = mnd_emalloc((size_t)(set->row_count * result->meta->field_count *
sizeof(zval *)));
+ if (!set->data) {
+ SET_OOM_ERROR(*conn->error_info);
+ DBG_RETURN(NULL);
+ }
+ memset(set->data, 0, (size_t)(set->row_count * result->meta->field_count *
sizeof(zval *)));
+ }
+ /* Position at the first row */
+ set->data_cursor = set->data;
+
+
/* libmysql API docs say it should be so for SELECT statements */
stmt->upsert_status->affected_rows = stmt->result->stored_data->row_count;
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index fbf8ea0..944999b 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1155,6 +1155,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const
c
*/
}
/* Overflow ? */
+#if 0
if (set->row_count) {
/* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have
narrower range than uint64_t */
if (set->row_count * meta->field_count * sizeof(zval *) > SIZE_MAX) {
@@ -1171,7 +1172,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const
c
}
memset(set->data, 0, (size_t)(set->row_count * meta->field_count * sizeof(zval *)));
}
-
+#endif
MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats,
binary_protocol? STAT_ROWS_BUFFERED_FROM_CLIENT_PS:
STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL,
@@ -1203,9 +1204,6 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const
c
if (ret == FAIL) {
COPY_CLIENT_ERROR(set->error_info, row_packet->error_info);
} else {
- /* Position at the first row */
- set->data_cursor = set->data;
-
/* libmysql's documentation says it should be so for SELECT statements */
conn->upsert_status->affected_rows = set->row_count;
}
@@ -1255,7 +1253,27 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
SET_OOM_ERROR(*conn->error_info);
}
DBG_RETURN(NULL);
+ } else {
+ /* Overflow ? */
+ MYSQLND_RES_BUFFERED * set = result->stored_data;
+ if (set->row_count) {
+ /* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have
narrower range than uint64_t */
+ if (set->row_count * result->meta->field_count * sizeof(zval *) > SIZE_MAX) {
+ SET_OOM_ERROR(*conn->error_info);
+ DBG_RETURN(NULL);
+ }
+ /* if pecalloc is used valgrind barks gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch
revision 135036] (SUSE Linux) */
+ set->data = mnd_emalloc((size_t)(set->row_count * result->meta->field_count *
sizeof(zval *)));
+ if (!set->data) {
+ SET_OOM_ERROR(*conn->error_info);
+ DBG_RETURN(NULL);
+ }
+ memset(set->data, 0, (size_t)(set->row_count * result->meta->field_count *
sizeof(zval *)));
+ }
+ /* Position at the first row */
+ set->data_cursor = set->data;
}
+
/* libmysql's documentation says it should be so for SELECT statements */
conn->upsert_status->affected_rows = result->stored_data->row_count;