Skip to content

Commit 0483798

Browse files
committed
Fix one leak
1. GC_DELREF isn't enough because the hash table may hold the last reference 2. The reference should be deleted inside the odbc_result_free function to avoid forgetting to call it in other places.
1 parent 54ef55f commit 0483798

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/odbc/php_odbc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ static void odbc_result_free(odbc_result *res)
228228

229229
HashTable *tmp = &res->conn_ptr->results;
230230
res->conn_ptr = NULL;
231-
zend_hash_index_del(tmp, res->index);
231+
zend_result status = zend_hash_index_del(tmp, res->index);
232+
ZEND_ASSERT(status == SUCCESS);
232233
}
233234

234235
static void odbc_result_free_obj(zend_object *obj) {
@@ -281,7 +282,6 @@ static void close_results_with_connection(odbc_connection *conn) {
281282
if (result->conn_ptr) {
282283
odbc_result_free(result);
283284
}
284-
GC_DELREF(&result->std);
285285
} ZEND_HASH_FOREACH_END();
286286

287287
zend_hash_clean(&conn->results);
@@ -2126,7 +2126,7 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
21262126
object_init_ex(zv, odbc_connection_ce);
21272127
link = Z_ODBC_LINK_P(zv);
21282128
link->connection = pecalloc(1, sizeof(odbc_connection), persistent);
2129-
zend_hash_init(&link->connection->results, 0, NULL, NULL, 1);
2129+
zend_hash_init(&link->connection->results, 0, NULL, ZVAL_PTR_DTOR, 1);
21302130
link->persistent = persistent;
21312131
link->hash = zend_string_init(hash, hash_len, persistent);
21322132
ret = SQLAllocEnv(&link->connection->henv);

0 commit comments

Comments
 (0)