summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/sqlite_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite/sqlite_driver.c')
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index 319c9109ba..cbaec45ab9 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -42,7 +42,10 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
einfo->line = line;
if (einfo->errcode != SQLITE_OK) {
- einfo->errmsg = (char*)sqlite3_errmsg(H->db);
+ if (einfo->errmsg) {
+ efree(einfo->errmsg);
+ }
+ einfo->errmsg = estrdup((char*)sqlite3_errmsg(H->db));
} else { /* no error */
strcpy(*pdo_err, PDO_ERR_NONE);
return 0;
@@ -133,11 +136,17 @@ static int sqlite_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
if (H) {
+ pdo_sqlite_error_info *einfo = &H->einfo;
+
pdo_sqlite_cleanup_callbacks(H TSRMLS_CC);
if (H->db) {
sqlite3_close(H->db);
H->db = NULL;
}
+ if (einfo->errmsg) {
+ efree(einfo->errmsg);
+ einfo->errmsg = NULL;
+ }
pefree(H, dbh->is_persistent);
dbh->driver_data = NULL;
}