/ Check-in [b73ad305]
Login

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

Overview
Comment:Skip calling the virtual table xDestroy method when it is null.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b73ad305a6b7cb84fe0a1efb334b8e4592e21c40
User & Date: mistachkin 2015-08-20 21:14:31
Context
2015-08-20
23:21
Fix corner-case memory management issues in table-valued functions. Change virtual table handling so that if xDestroy is missing the table is eponymous only even if xCreate is present. check-in: 774e6a14 user: drh tags: trunk
21:14
Skip calling the virtual table xDestroy method when it is null. check-in: b73ad305 user: mistachkin tags: trunk
20:21
Fix stray variable declaration for C89. check-in: 17eb7f18 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vtab.c.

   797    797   int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
   798    798     int rc = SQLITE_OK;
   799    799     Table *pTab;
   800    800   
   801    801     pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
   802    802     if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
   803    803       VTable *p;
          804  +    int (*xDestroy)(sqlite3_vtab *);
   804    805       for(p=pTab->pVTable; p; p=p->pNext){
   805    806         assert( p->pVtab );
   806    807         if( p->pVtab->nRef>0 ){
   807    808           return SQLITE_LOCKED;
   808    809         }
   809    810       }
   810    811       p = vtabDisconnectAll(db, pTab);
   811         -    rc = p->pMod->pModule->xDestroy(p->pVtab);
          812  +    xDestroy = p->pMod->pModule->xDestroy;
          813  +    rc = xDestroy ? xDestroy(p->pVtab) : SQLITE_OK;
   812    814       /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
   813    815       if( rc==SQLITE_OK ){
   814    816         assert( pTab->pVTable==p && p->pNext==0 );
   815    817         p->pVtab = 0;
   816    818         pTab->pVTable = 0;
   817    819         sqlite3VtabUnlock(p);
   818    820       }