summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/sqlite/src/legacy.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite/sqlite/src/legacy.c')
-rw-r--r--ext/pdo_sqlite/sqlite/src/legacy.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/ext/pdo_sqlite/sqlite/src/legacy.c b/ext/pdo_sqlite/sqlite/src/legacy.c
index f575f1f0c..c75791e1b 100644
--- a/ext/pdo_sqlite/sqlite/src/legacy.c
+++ b/ext/pdo_sqlite/sqlite/src/legacy.c
@@ -54,8 +54,8 @@ int sqlite3_exec(
pStmt = 0;
rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover);
+ assert( rc==SQLITE_OK || pStmt==0 );
if( rc!=SQLITE_OK ){
- if( pStmt ) sqlite3_finalize(pStmt);
continue;
}
if( !pStmt ){
@@ -68,9 +68,8 @@ int sqlite3_exec(
nCallback = 0;
nCol = sqlite3_column_count(pStmt);
- azCols = sqliteMalloc(2*nCol*sizeof(const char *));
- if( nCol && !azCols ){
- rc = SQLITE_NOMEM;
+ azCols = sqliteMalloc(2*nCol*sizeof(const char *) + 1);
+ if( azCols==0 ){
goto exec_out;
}
@@ -122,11 +121,9 @@ exec_out:
if( pStmt ) sqlite3_finalize(pStmt);
if( azCols ) sqliteFree(azCols);
- if( sqlite3_malloc_failed ){
- rc = SQLITE_NOMEM;
- }
+ rc = sqlite3ApiExit(0, rc);
if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
- *pzErrMsg = malloc(1+strlen(sqlite3_errmsg(db)));
+ *pzErrMsg = sqlite3_malloc(1+strlen(sqlite3_errmsg(db)));
if( *pzErrMsg ){
strcpy(*pzErrMsg, sqlite3_errmsg(db));
}