Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/mysqlnd/mysqlnd_block_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ PHPAPI void
mysqlnd_mempool_restore_state(MYSQLND_MEMORY_POOL * pool)
{
DBG_ENTER("mysqlnd_mempool_restore_state");
#if ZEND_DEBUG
ZEND_ASSERT(pool->checkpoint);
#endif
if (pool->checkpoint) {
mysqlnd_arena_release(&pool->arena, pool->checkpoint);
pool->last = NULL;
Expand Down
26 changes: 11 additions & 15 deletions ext/mysqlnd/mysqlnd_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, free_result)(MYSQLND_RES_UNBUFFERED *
result->row_packet = NULL;
}

mysqlnd_mempool_restore_state(result->result_set_memory_pool);

DBG_VOID_RETURN;
}
/* }}} */
Expand Down Expand Up @@ -261,8 +259,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered, free_result)(MYSQLND_RES_BUFFERED * cons
set->row_buffers = NULL;
}

mysqlnd_mempool_restore_state(set->result_set_memory_pool);

DBG_VOID_RETURN;
}
/* }}} */
Expand All @@ -275,6 +271,12 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES * result)
DBG_ENTER("mysqlnd_res::free_result_buffers");
DBG_INF_FMT("%s", result->unbuf? "unbuffered":(result->stored_data? "buffered":"unknown"));

if (result->meta) {
ZEND_ASSERT(zend_arena_contains(result->memory_pool->arena, result->meta));
result->meta->m->free_metadata(result->meta);
result->meta = NULL;
}

if (result->unbuf) {
result->unbuf->m.free_result(result->unbuf, result->conn? result->conn->stats : NULL);
result->unbuf = NULL;
Expand All @@ -283,6 +285,9 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES * result)
result->stored_data = NULL;
}

mysqlnd_mempool_restore_state(result->memory_pool);
mysqlnd_mempool_save_state(result->memory_pool);

DBG_VOID_RETURN;
}
/* }}} */
Expand All @@ -294,12 +299,6 @@ void MYSQLND_METHOD(mysqlnd_res, free_result_contents_internal)(MYSQLND_RES * re
{
DBG_ENTER("mysqlnd_res::free_result_contents_internal");

if (result->meta) {
ZEND_ASSERT(zend_arena_contains(result->memory_pool->arena, result->meta));
result->meta->m->free_metadata(result->meta);
result->meta = NULL;
}

result->m.free_result_buffers(result);

DBG_VOID_RETURN;
Expand Down Expand Up @@ -1926,6 +1925,8 @@ mysqlnd_result_init(const unsigned int field_count)
ret->field_count = field_count;
ret->m = *mysqlnd_result_get_methods();

mysqlnd_mempool_save_state(pool);

DBG_RETURN(ret);
}
/* }}} */
Expand All @@ -1941,7 +1942,6 @@ mysqlnd_result_unbuffered_init(MYSQLND_RES *result, const unsigned int field_cou

DBG_ENTER("mysqlnd_result_unbuffered_init");

mysqlnd_mempool_save_state(pool);
ret = pool->get_chunk(pool, alloc_size);
memset(ret, 0, alloc_size);

Expand Down Expand Up @@ -1976,12 +1976,10 @@ mysqlnd_result_buffered_zval_init(MYSQLND_RES * result, const unsigned int field

DBG_ENTER("mysqlnd_result_buffered_zval_init");

mysqlnd_mempool_save_state(pool);
ret = pool->get_chunk(pool, alloc_size);
memset(ret, 0, alloc_size);

if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this call can't actually fail ... we should make it void in master.

mysqlnd_mempool_restore_state(pool);
DBG_RETURN(NULL);
}

Expand Down Expand Up @@ -2019,12 +2017,10 @@ mysqlnd_result_buffered_c_init(MYSQLND_RES * result, const unsigned int field_co

DBG_ENTER("mysqlnd_result_buffered_c_init");

mysqlnd_mempool_save_state(pool);
ret = pool->get_chunk(pool, alloc_size);
memset(ret, 0, alloc_size);

if (FAIL == mysqlnd_error_info_init(&ret->error_info, 0)) {
mysqlnd_mempool_restore_state(pool);
DBG_RETURN(NULL);
}

Expand Down