/ Check-in [526ee07d]
Login

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

Overview
Comment:Fix a memory leak following failure to open an external CSV file in the csv.c extension.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 526ee07d19dbc8fd1af3a02a8da12b337020a4be40e045da9a19d0a7c2b6ab54
User & Date: drh 2018-04-24 10:57:10
Context
2018-04-24
13:07
Enhance the CLI to render EXPLAIN QUERY PLAN using an ASCII-art graph. This works with ".eqp" modes and when the query begins with exactly "EXPLAIN QUERY PLAN". To see the original output format, add extra space characters in between words of the initial "EXPLAIN QUERY PLAN". check-in: f53716ee user: drh tags: trunk
10:57
Fix a memory leak following failure to open an external CSV file in the csv.c extension. check-in: 526ee07d user: drh tags: trunk
01:10
In EXPLAIN QUERY PLAN output, do not show an EXECUTE LIST SUBQUERY line for IN operators where the RHS is a list and not a subquery, since in that case there is no SUBQUERY to execute. check-in: 8bc0207a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/csv.c.

   128    128       p->zIn = sqlite3_malloc( CSV_INBUFSZ );
   129    129       if( p->zIn==0 ){
   130    130         csv_errmsg(p, "out of memory");
   131    131         return 1;
   132    132       }
   133    133       p->in = fopen(zFilename, "rb");
   134    134       if( p->in==0 ){
          135  +      sqlite3_free(p->zIn);
   135    136         csv_reader_reset(p);
   136    137         csv_errmsg(p, "cannot open '%s' for reading", zFilename);
   137    138         return 1;
   138    139       }
   139    140     }else{
   140    141       assert( p->in==0 );
   141    142       p->zIn = (char*)zData;

Changes to test/csv01.test.

   136    136         columns=4,
   137    137         schema=
   138    138         'CREATE TABLE t3(a,b,c,d) WITHOUT ROWID',
   139    139         testflags=1
   140    140         );
   141    141   } {1 {vtable constructor failed: t5}}
   142    142   
          143  +# 2018-04-24
          144  +# Memory leak reported on the sqlite-users mailing list by Ralf Junker.
          145  +#
          146  +do_catchsql_test 4.3 {
          147  +  CREATE VIRTUAL TABLE IF NOT EXISTS temp.t1
          148  +  USING csv(filename='FileDoesNotExist.csv');
          149  +} {1 {cannot open 'FileDoesNotExist.csv' for reading}}
   143    150   
   144    151   finish_test