/ Check-in [e8566cf5]
Login

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

Overview
Comment:Fix segfault that occurs when opening a non-existing database in the shell then immediately doing ".q". (CVS 986)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e8566cf5a381fa7655caacbc0fe95091e1137fea
User & Date: drh 2003-05-19 23:55:30
Context
2003-05-29
04:21
Added typeof() operator. Minor additions for ATTACH/DETACH. (CVS 987) check-in: 8b8fa0ff user: jplyon tags: trunk
2003-05-19
23:55
Fix segfault that occurs when opening a non-existing database in the shell then immediately doing ".q". (CVS 986) check-in: e8566cf5 user: drh tags: trunk
2003-05-17
19:23
Additional attach testing. I now believe that ticket #317 was fixed by check-in (981). (CVS 985) check-in: 24191373 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.79 2003/05/13 00:24:41 drh Exp $
           15  +** $Id: shell.c,v 1.80 2003/05/19 23:55:30 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include "sqlite.h"
    21     21   #include <ctype.h>
    22     22   
................................................................................
   763    763       }
   764    764       if( nArg >= 3) {
   765    765         strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);
   766    766       }
   767    767     }else
   768    768   
   769    769     if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){
   770         -    sqlite_close(p->db);
          770  +    if( p->db ) sqlite_close(p->db);
   771    771       exit(0);
   772    772     }else
   773    773   
   774    774     if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){
   775    775       FILE *alt = fopen(azArg[1], "r");
   776    776       if( alt==0 ){
   777    777         fprintf(stderr,"can't open \"%s\"\n", azArg[1]);