Fossil SCM
Always unlink prepared statements from the Stmt list prior to finalizing them. This prevents an error in db_finalize() from triggering a rollback and hence a recursive call to sqlite3_finalize().
Commit
42d821a714d092a86dfcdf6b815300b7d5ce228f5e42c10fe8658c4be8f2881d
Parent
7b5099ea44a5b03…
1 file changed
+5
-5
M
src/db.c
+5
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -492,15 +492,10 @@ | ||
| 492 | 492 | db_check_result(rc); |
| 493 | 493 | return rc; |
| 494 | 494 | } |
| 495 | 495 | int db_finalize(Stmt *pStmt){ |
| 496 | 496 | int rc; |
| 497 | - db_stats(pStmt); | |
| 498 | - blob_reset(&pStmt->sql); | |
| 499 | - rc = sqlite3_finalize(pStmt->pStmt); | |
| 500 | - db_check_result(rc); | |
| 501 | - pStmt->pStmt = 0; | |
| 502 | 497 | if( pStmt->pNext ){ |
| 503 | 498 | pStmt->pNext->pPrev = pStmt->pPrev; |
| 504 | 499 | } |
| 505 | 500 | if( pStmt->pPrev ){ |
| 506 | 501 | pStmt->pPrev->pNext = pStmt->pNext; |
| @@ -507,10 +502,15 @@ | ||
| 507 | 502 | }else if( db.pAllStmt==pStmt ){ |
| 508 | 503 | db.pAllStmt = pStmt->pNext; |
| 509 | 504 | } |
| 510 | 505 | pStmt->pNext = 0; |
| 511 | 506 | pStmt->pPrev = 0; |
| 507 | + db_stats(pStmt); | |
| 508 | + blob_reset(&pStmt->sql); | |
| 509 | + rc = sqlite3_finalize(pStmt->pStmt); | |
| 510 | + db_check_result(rc); | |
| 511 | + pStmt->pStmt = 0; | |
| 512 | 512 | return rc; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /* |
| 516 | 516 | ** Return the rowid of the most recent insert |
| 517 | 517 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -492,15 +492,10 @@ | |
| 492 | db_check_result(rc); |
| 493 | return rc; |
| 494 | } |
| 495 | int db_finalize(Stmt *pStmt){ |
| 496 | int rc; |
| 497 | db_stats(pStmt); |
| 498 | blob_reset(&pStmt->sql); |
| 499 | rc = sqlite3_finalize(pStmt->pStmt); |
| 500 | db_check_result(rc); |
| 501 | pStmt->pStmt = 0; |
| 502 | if( pStmt->pNext ){ |
| 503 | pStmt->pNext->pPrev = pStmt->pPrev; |
| 504 | } |
| 505 | if( pStmt->pPrev ){ |
| 506 | pStmt->pPrev->pNext = pStmt->pNext; |
| @@ -507,10 +502,15 @@ | |
| 507 | }else if( db.pAllStmt==pStmt ){ |
| 508 | db.pAllStmt = pStmt->pNext; |
| 509 | } |
| 510 | pStmt->pNext = 0; |
| 511 | pStmt->pPrev = 0; |
| 512 | return rc; |
| 513 | } |
| 514 | |
| 515 | /* |
| 516 | ** Return the rowid of the most recent insert |
| 517 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -492,15 +492,10 @@ | |
| 492 | db_check_result(rc); |
| 493 | return rc; |
| 494 | } |
| 495 | int db_finalize(Stmt *pStmt){ |
| 496 | int rc; |
| 497 | if( pStmt->pNext ){ |
| 498 | pStmt->pNext->pPrev = pStmt->pPrev; |
| 499 | } |
| 500 | if( pStmt->pPrev ){ |
| 501 | pStmt->pPrev->pNext = pStmt->pNext; |
| @@ -507,10 +502,15 @@ | |
| 502 | }else if( db.pAllStmt==pStmt ){ |
| 503 | db.pAllStmt = pStmt->pNext; |
| 504 | } |
| 505 | pStmt->pNext = 0; |
| 506 | pStmt->pPrev = 0; |
| 507 | db_stats(pStmt); |
| 508 | blob_reset(&pStmt->sql); |
| 509 | rc = sqlite3_finalize(pStmt->pStmt); |
| 510 | db_check_result(rc); |
| 511 | pStmt->pStmt = 0; |
| 512 | return rc; |
| 513 | } |
| 514 | |
| 515 | /* |
| 516 | ** Return the rowid of the most recent insert |
| 517 |