diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2005-12-19 16:33:46 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2005-12-19 16:33:46 +0000 |
commit | 4e09db1dbfdc5c3654c4b5352174d224075d4b0e (patch) | |
tree | 6f43965f18d8eddcda1d2ca92f5f0ab6929d0dd6 /ext/pdo_sqlite/sqlite_driver.c | |
parent | 78244d64af7ddd2058a6768a9c19e84af26b1a8e (diff) | |
download | php-git-4e09db1dbfdc5c3654c4b5352174d224075d4b0e.tar.gz |
Fixed possible memory corruption.
Diffstat (limited to 'ext/pdo_sqlite/sqlite_driver.c')
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index a046969b2d..d53dfa8c1a 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; } |