From: Ilia Alshanetsky Date: Mon, 19 Dec 2005 16:34:00 +0000 (+0000) Subject: MFB51: Fixed possible memory corruption. X-Git-Tag: RELEASE_1_0_4~316 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c98f6435df7f1f2ec084247fffa7f100b674d03;p=php MFB51: Fixed possible memory corruption. --- 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; }