@@ -119,29 +119,30 @@ MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool
119
119
DBG_ENTER ("mysqlnd_mempool_get_chunk" );
120
120
121
121
chunk = mnd_malloc (sizeof (MYSQLND_MEMORY_POOL_CHUNK ));
122
-
123
- chunk -> free_chunk = mysqlnd_mempool_free_chunk ;
124
- chunk -> resize_chunk = mysqlnd_mempool_resize_chunk ;
125
- chunk -> size = size ;
126
- /*
127
- Should not go over MYSQLND_MAX_PACKET_SIZE, since we
128
- expect non-arena memory in mysqlnd_wireprotocol.c . We
129
- realloc the non-arena memory.
130
- */
131
- chunk -> pool = pool ;
132
- if (size > pool -> free_size ) {
133
- chunk -> from_pool = FALSE;
134
- chunk -> ptr = mnd_malloc (size );
135
- if (!chunk -> ptr ) {
136
- chunk -> free_chunk (chunk TSRMLS_CC );
137
- chunk = NULL ;
122
+ if (chunk ) {
123
+ chunk -> free_chunk = mysqlnd_mempool_free_chunk ;
124
+ chunk -> resize_chunk = mysqlnd_mempool_resize_chunk ;
125
+ chunk -> size = size ;
126
+ /*
127
+ Should not go over MYSQLND_MAX_PACKET_SIZE, since we
128
+ expect non-arena memory in mysqlnd_wireprotocol.c . We
129
+ realloc the non-arena memory.
130
+ */
131
+ chunk -> pool = pool ;
132
+ if (size > pool -> free_size ) {
133
+ chunk -> from_pool = FALSE;
134
+ chunk -> ptr = mnd_malloc (size );
135
+ if (!chunk -> ptr ) {
136
+ chunk -> free_chunk (chunk TSRMLS_CC );
137
+ chunk = NULL ;
138
+ }
139
+ } else {
140
+ chunk -> from_pool = TRUE;
141
+ ++ pool -> refcount ;
142
+ chunk -> ptr = pool -> arena + (pool -> arena_size - pool -> free_size );
143
+ /* Last step, update free_size */
144
+ pool -> free_size -= size ;
138
145
}
139
- } else {
140
- chunk -> from_pool = TRUE;
141
- ++ pool -> refcount ;
142
- chunk -> ptr = pool -> arena + (pool -> arena_size - pool -> free_size );
143
- /* Last step, update free_size */
144
- pool -> free_size -= size ;
145
146
}
146
147
DBG_RETURN (chunk );
147
148
}
0 commit comments