diff options
| author | Andrey Hristov <andrey@php.net> | 2009-05-28 16:35:16 +0000 |
|---|---|---|
| committer | Andrey Hristov <andrey@php.net> | 2009-05-28 16:35:16 +0000 |
| commit | 09b56ed2a5142b7a303622309ff275cac5177d05 (patch) | |
| tree | 2b26b3f7c317c81fde7376f7ddf5f536d402f6e7 /ext/mysqlnd/mysqlnd_result.c | |
| parent | f9fb575cd7fbb13dfc380301ee4632905e809976 (diff) | |
| download | php-git-09b56ed2a5142b7a303622309ff275cac5177d05.tar.gz | |
Fix a problem with cursors, which did not happen with unbuffered PS for
some reason. Double free of the data, which led to valgrind warnigns.
The fix actually optimizes the code in this cases because the old code
used copy_ctor while the new one skips it because it is not needed.
Transferring data ownership and nulling works best, for PS where we
always copy the string from the result set, unlike the text protocol.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_result.c')
| -rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index f791fd0fb5..e161f28854 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -143,10 +143,13 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC) DBG_VOID_RETURN; } + DBG_INF_FMT("last_row_data=%p", unbuf->last_row_data); if (unbuf->last_row_data) { unsigned int i, ctor_called_count = 0; zend_bool copy_ctor_called; MYSQLND_STATS *global_stats = result->conn? &result->conn->stats:NULL; + + DBG_INF_FMT("%u columns to free", result->field_count); for (i = 0; i < result->field_count; i++) { mysqlnd_palloc_zval_ptr_dtor(&(unbuf->last_row_data[i]), result->zval_cache, result->type, @@ -155,6 +158,7 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC) ctor_called_count++; } } + DBG_INF_FMT("copy_ctor_called_count=%u", ctor_called_count); /* By using value3 macros we hold a mutex only once, there is no value2 */ MYSQLND_INC_CONN_STATISTIC_W_VALUE3(global_stats, STAT_COPY_ON_WRITE_PERFORMED, @@ -168,6 +172,7 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC) unbuf->last_row_data = NULL; } if (unbuf->last_row_buffer) { + DBG_INF("Freeing last row buffer"); /* Nothing points to this buffer now, free it */ unbuf->last_row_buffer->free_chunk(unbuf->last_row_buffer, TRUE TSRMLS_CC); unbuf->last_row_buffer = NULL; |
