SQLite

Check-in [52f463d2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem that could cause a crash if a blob handle were closed after the associated database handle was closed using sqlite3_close_v2().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 52f463d29407fad691c42b13462880e7605603c9be9f480d18e953a0ef78149a
User & Date: dan 2019-07-15 13:58:28
Context
2019-07-16
05:11
Call ioctl() with the correct signature on both Android and stock Linux. (check-in: 24225349 user: dan tags: trunk)
2019-07-15
13:58
Fix a problem that could cause a crash if a blob handle were closed after the associated database handle was closed using sqlite3_close_v2(). (check-in: 52f463d2 user: dan tags: trunk)
2019-07-14
00:15
Mark an unreachable branch using ALWAYS(). (check-in: 0fff105a user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeblob.c.

351
352
353
354
355
356
357

358
359
360
361
362

363
364
365
366
367
368
369
*/
int sqlite3_blob_close(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  int rc;
  sqlite3 *db;

  if( p ){

    db = p->db;
    sqlite3_mutex_enter(db->mutex);
    rc = sqlite3_finalize(p->pStmt);
    sqlite3DbFree(db, p);
    sqlite3_mutex_leave(db->mutex);

  }else{
    rc = SQLITE_OK;
  }
  return rc;
}

/*







>


<


>







351
352
353
354
355
356
357
358
359
360

361
362
363
364
365
366
367
368
369
370
*/
int sqlite3_blob_close(sqlite3_blob *pBlob){
  Incrblob *p = (Incrblob *)pBlob;
  int rc;
  sqlite3 *db;

  if( p ){
    sqlite3_stmt *pStmt = p->pStmt;
    db = p->db;
    sqlite3_mutex_enter(db->mutex);

    sqlite3DbFree(db, p);
    sqlite3_mutex_leave(db->mutex);
    rc = sqlite3_finalize(pStmt);
  }else{
    rc = SQLITE_OK;
  }
  return rc;
}

/*

Changes to test/close.test.

74
75
76
77
78
79
80







81
82
    sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
  } msg] $msg
} {1 {(21) bad parameter or other API misuse}}

do_test 1.4.4 {
  sqlite3_finalize $STMT
} {SQLITE_OK}








finish_test







>
>
>
>
>
>
>


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
    sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
  } msg] $msg
} {1 {(21) bad parameter or other API misuse}}

do_test 1.4.4 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

do_test 1.5 {
  set DB [sqlite3_open test.db]
  sqlite3_blob_open $DB main t1 x 2 0 BLOB
  sqlite3_close_v2 $DB
  sqlite3_blob_close $BLOB
} {}

finish_test