Skip to content

Instantly share code, notes, and snippets.

@tony2001
Last active January 10, 2017 09:37
Show Gist options
  • Save tony2001/7fca111760e0fd70963e7e4bed5e8ff3 to your computer and use it in GitHub Desktop.
Save tony2001/7fca111760e0fd70963e7e4bed5e8ff3 to your computer and use it in GitHub Desktop.
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 2184c00..0e9f9af 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1358,7 +1358,10 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const c
conn->upsert_status->server_status = row_packet->server_status;
}
/* save some memory */
- if (free_rows) {
+ if (set->row_count == 0) {
+ mnd_free(*row_buffers);
+ *row_buffers = NULL;
+ } else if (free_rows) {
/* 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 * sizeof(MYSQLND_MEMORY_POOL_CHUNK *) > SIZE_MAX) {
SET_OOM_ERROR(*conn->error_info);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment