From 863e93c99c953d39665df785cd3a9486d16c995b Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 3 Dec 2014 11:04:55 +0100 Subject: [PATCH] fix NULL deref with circular refs --- src/php_pqcur.c | 2 +- src/php_pqtxn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php_pqcur.c b/src/php_pqcur.c index 16057e8..1ff10da 100644 --- a/src/php_pqcur.c +++ b/src/php_pqcur.c @@ -31,7 +31,7 @@ static HashTable php_pqcur_object_prophandlers; static void cur_close(php_pqcur_object_t *obj TSRMLS_DC) { - if (obj->intern->open) { + if (obj->intern->open && obj->intern->conn->intern) { PGresult *res; smart_str cmd = {0}; diff --git a/src/php_pqtxn.c b/src/php_pqtxn.c index 0f5c4eb..b48cf7e 100644 --- a/src/php_pqtxn.c +++ b/src/php_pqtxn.c @@ -54,7 +54,7 @@ static void php_pqtxn_object_free(void *o TSRMLS_DC) fprintf(stderr, "FREE txn(#%d) %p (conn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->conn->zv.handle, obj->intern->conn); #endif if (obj->intern) { - if (obj->intern->open) { + if (obj->intern->open && obj->intern->conn->intern) { PGresult *res = PQexec(obj->intern->conn->intern->conn, "ROLLBACK"); if (res) { -- 2.30.2