X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqstm.c;h=7156145bcab1b053b7abaa21ed5534f0eb4273a1;hp=09b781b6b50b45046c5f72b0be50edddb5a863ec;hb=b73911f65df7f5877cef49d32844b655cebc4357;hpb=05da505f8005d3e65d3d5ad2cf143e8f36b425a3 diff --git a/src/php_pqstm.c b/src/php_pqstm.c index 09b781b..7156145 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -36,26 +36,28 @@ static void php_pqstm_object_free(void *o TSRMLS_DC) fprintf(stderr, "FREE stm(#%d) %p (conn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->conn->zv.handle, obj->intern->conn); #endif if (obj->intern) { - char *quoted_name = PQescapeIdentifier(obj->intern->conn->intern->conn, obj->intern->name, strlen(obj->intern->name)); + if (obj->intern->conn->intern) { + char *quoted_name = PQescapeIdentifier(obj->intern->conn->intern->conn, obj->intern->name, strlen(obj->intern->name)); - php_pq_callback_dtor(&obj->intern->conn->intern->onevent); + php_pq_callback_dtor(&obj->intern->conn->intern->onevent); - if (quoted_name) { - PGresult *res; - smart_str cmd = {0}; + if (quoted_name) { + PGresult *res; + smart_str cmd = {0}; - smart_str_appends(&cmd, "DEALLOCATE "); - smart_str_appends(&cmd, quoted_name); - smart_str_0(&cmd); - PQfreemem(quoted_name); + smart_str_appends(&cmd, "DEALLOCATE "); + smart_str_appends(&cmd, quoted_name); + smart_str_0(&cmd); + PQfreemem(quoted_name); - if ((res = PQexec(obj->intern->conn->intern->conn, cmd.c))) { - PHP_PQclear(res); + if ((res = PQexec(obj->intern->conn->intern->conn, cmd.c))) { + PHP_PQclear(res); + } + smart_str_free(&cmd); } - smart_str_free(&cmd); - } - php_pq_object_delref(obj->intern->conn TSRMLS_CC); + php_pq_object_delref(obj->intern->conn TSRMLS_CC); + } efree(obj->intern->name); zend_hash_destroy(&obj->intern->bound); if (obj->intern->params) {