diff options
| author | Ondřej Surý <ondrej@sury.org> | 2014-03-27 15:35:16 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2014-03-27 15:35:16 +0100 |
| commit | 30bdcf2392ef8cc7b8b4a07b49367571ae1db286 (patch) | |
| tree | c98975e6a71c722e7ce3b31c7c221ceb0e9a1f25 /ext/mysqlnd | |
| parent | d67160a566757f858e5883201e518230f5221c6b (diff) | |
| download | php-30bdcf2392ef8cc7b8b4a07b49367571ae1db286.tar.gz | |
New upstream version 5.6.0~alpha3+dfsgupstream/5.6.0_alpha3+dfsg
Diffstat (limited to 'ext/mysqlnd')
| -rw-r--r-- | ext/mysqlnd/mysqlnd_ps.c | 20 | ||||
| -rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 40 |
2 files changed, 40 insertions, 20 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 8096cbbbd..fa2abc71d 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 fbf8ea031..a4fb9f6cf 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -1155,23 +1155,6 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const c */ } /* Overflow ? */ - 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) { - SET_OOM_ERROR(*conn->error_info); - ret = FAIL; - goto end; - } - /* 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 * meta->field_count * sizeof(zval *))); - if (!set->data) { - SET_OOM_ERROR(*conn->error_info); - ret = FAIL; - goto end; - } - memset(set->data, 0, (size_t)(set->row_count * meta->field_count * sizeof(zval *))); - } - MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, binary_protocol? STAT_ROWS_BUFFERED_FROM_CLIENT_PS: STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL, @@ -1203,9 +1186,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 +1235,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; |
