From: Michael Wallner Date: Wed, 3 May 2017 07:16:43 +0000 (+0200) Subject: fixes #24 X-Git-Tag: v2.1.2~3 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=commitdiff_plain;h=65b81572a092cc9aa9b980f30f7793b45803a211;hp=6051d47777db6de82448e063a1bd9ab30e30de1d fixes #24 Segmentation fault after pg_terminate_backend --- diff --git a/src/php_pqconn.c b/src/php_pqconn.c index f2a0e0c..d0ddfef 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -1146,11 +1146,12 @@ static PHP_METHOD(pqconn, getResult) { throw_exce(EX_UNINITIALIZED, "pq\\Connection not initialized"); } else { PGresult *res = PQgetResult(obj->intern->conn); + php_pq_object_t *res_obj; - if (!res) { - RETVAL_NULL(); + if (res && (res_obj = PQresultInstanceData(res, php_pqconn_event))) { + php_pq_object_to_zval_no_addref(res_obj, return_value); } else { - php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), return_value); + RETVAL_NULL(); } php_pqconn_notify_listeners(obj);