com php-src: Free error and message strings when cleaning up PDO instances that use pdo_dblib: ext/pdo_dblib/dblib_driver.c
ext/pdo_dblib/dblib_stmt.c ext/pdo_dblib/pdo_dblib .c ext/pdo_dblib/php_pdo_dblib_int.h
| From: | Adam Baratz | Date: | Tue, 13 Sep 2016 20:43:30 +0000 |
| Subject: | com php-src: Free error and message strings when cleaning up PDO instances that use pdo_dblib: ext/pdo_dblib/dblib_driver.c ext/pdo_dblib/dblib_stmt.c ext/pdo_dblib/pdo_dblib .c ext/pdo_dblib/php_pdo_dblib_int.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94504@lists.php.net to get a copy of this message | ||
Commit: 69eef8c361c930d406254db16d0479fa74075e92
Author: Adam Baratz <adambaratz@php.net> Tue, 13 Sep 2016 16:43:30 -0400
Parents: efadcb0390c3ef1ad0b3c445f886dc697bae44a7
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69eef8c361c930d406254db16d0479fa74075e92
Log:
Free error and message strings when cleaning up PDO instances that use pdo_dblib
Changed paths:
M ext/pdo_dblib/dblib_driver.c
M ext/pdo_dblib/dblib_stmt.c
M ext/pdo_dblib/pdo_dblib.c
M ext/pdo_dblib/php_pdo_dblib_int.h
Diff:
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 13ddd8a..66e7d79 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -88,6 +88,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh)
}
pefree(H, dbh->is_persistent);
dbh->driver_data = NULL;
+ pdo_dblib_err_dtor(&H->err);
}
return 0;
}
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 311d856..1c0577e 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -95,22 +95,6 @@ static char *pdo_dblib_get_field_name(int type)
}
/* }}} */
-static void pdo_dblib_err_dtor(pdo_dblib_err *err)
-{
- if (err->dberrstr) {
- efree(err->dberrstr);
- err->dberrstr = NULL;
- }
- if (err->lastmsg) {
- efree(err->lastmsg);
- err->lastmsg = NULL;
- }
- if (err->oserrstr) {
- efree(err->oserrstr);
- err->oserrstr = NULL;
- }
-}
-
static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
diff --git a/ext/pdo_dblib/pdo_dblib.c b/ext/pdo_dblib/pdo_dblib.c
index b855224..9d11933 100644
--- a/ext/pdo_dblib/pdo_dblib.c
+++ b/ext/pdo_dblib/pdo_dblib.c
@@ -152,6 +152,26 @@ int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
return 0;
}
+void pdo_dblib_err_dtor(pdo_dblib_err *err)
+{
+ if (!err) {
+ return;
+ }
+
+ if (err->dberrstr) {
+ efree(err->dberrstr);
+ err->dberrstr = NULL;
+ }
+ if (err->lastmsg) {
+ efree(err->lastmsg);
+ err->lastmsg = NULL;
+ }
+ if (err->oserrstr) {
+ efree(err->oserrstr);
+ err->oserrstr = NULL;
+ }
+}
+
static PHP_GINIT_FUNCTION(dblib)
{
memset(dblib_globals, 0, sizeof(*dblib_globals));
diff --git a/ext/pdo_dblib/php_pdo_dblib_int.h b/ext/pdo_dblib/php_pdo_dblib_int.h
index 87a0038..01c538e 100644
--- a/ext/pdo_dblib/php_pdo_dblib_int.h
+++ b/ext/pdo_dblib/php_pdo_dblib_int.h
@@ -108,6 +108,8 @@ typedef struct {
char *lastmsg;
} pdo_dblib_err;
+void pdo_dblib_err_dtor(pdo_dblib_err *err);
+
typedef struct {
LOGINREC *login;
DBPROCESS *link;