SQLite

Check-in [ee88660029]
Login

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

Overview
Comment:Fix a bug in test module test_fs.c causing a segfault on OpenBSD.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ee886600297c2a03d9d1d10db88d3d107b48e5d4de5e5d91b0ab16cc7c447ede
User & Date: dan 2019-04-15 19:17:50.242
Context
2019-04-16
10:51
Avoid a sanitizer error in test1.c. Have releasetest.tcl/wapptest.tcl create a file called "makecommand.sh" that can be used to rerun a test from the command line. (check-in: 4de4480ffd user: dan tags: trunk)
2019-04-15
19:17
Fix a bug in test module test_fs.c causing a segfault on OpenBSD. (check-in: ee88660029 user: dan tags: trunk)
15:41
Fix a problem with the user-auth extension and deserializing in-memory databases. (check-in: 09fa0b3c4a user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/test_fs.c.
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139







-
+







};

struct FsdirCsr {
  sqlite3_vtab_cursor base;
  char *zDir;                     /* Buffer containing directory scanned */
  DIR *pDir;                      /* Open directory */
  sqlite3_int64 iRowid;
  struct DIRENT entry;            /* Current entry */
  struct DIRENT *pEntry;
};

/*
** This function is the implementation of both the xConnect and xCreate
** methods of the fsdir virtual table.
**
** The argv[] array contains the following:
232
233
234
235
236
237
238
239
240
241


242
243
244
245
246
247
248
249
250
251
232
233
234
235
236
237
238



239
240



241
242
243
244
245
246
247







-
-
-
+
+
-
-
-







/*
** Skip the cursor to the next entry.
*/
static int fsdirNext(sqlite3_vtab_cursor *cur){
  FsdirCsr *pCsr = (FsdirCsr*)cur;

  if( pCsr->pDir ){
    struct DIRENT *pRes = 0;
    pRes = readdir(pCsr->pDir);
    if( pRes!=0 ){
    pCsr->pEntry = readdir(pCsr->pDir);
    if( pCsr->pEntry==0 ){
      memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT));
    }
    if( pRes==0 ){
      closedir(pCsr->pDir);
      pCsr->pDir = 0;
    }
    pCsr->iRowid++;
  }

  return SQLITE_OK;
300
301
302
303
304
305
306
307

308
309
310
311
312
313
314
296
297
298
299
300
301
302

303
304
305
306
307
308
309
310







-
+







  FsdirCsr *pCsr = (FsdirCsr*)cur;
  switch( i ){
    case 0: /* dir */
      sqlite3_result_text(ctx, pCsr->zDir, -1, SQLITE_STATIC);
      break;

    case 1: /* name */
      sqlite3_result_text(ctx, pCsr->entry.d_name, -1, SQLITE_TRANSIENT);
      sqlite3_result_text(ctx, pCsr->pEntry->d_name, -1, SQLITE_TRANSIENT);
      break;

    default:
      assert( 0 );
  }

  return SQLITE_OK;