/ Check-in [d0b6e9a0]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix a memory leak in the parser that can occur following a malloc failure. (CVS 4071)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d0b6e9a07e99cc1a7d7f61877918c9a247899996
User & Date: drh 2007-06-15 17:03:14
Context
2007-06-15
17:04
Fix typo in change comments for 3.4.0. Ticket #2416 (CVS 4072) check-in: 1f6f0330 user: drh tags: trunk
17:03
Fix a memory leak in the parser that can occur following a malloc failure. (CVS 4071) check-in: d0b6e9a0 user: drh tags: trunk
16:37
Fix an obscure memory leak in the SQL compiler.. (CVS 4070) check-in: d4ab9428 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.229 2007/05/30 10:36:47 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.230 2007/06/15 17:03:14 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   377    377   
   378    378   select(A) ::= oneselect(X).                      {A = X;}
   379    379   %ifndef SQLITE_OMIT_COMPOUND_SELECT
   380    380   select(A) ::= select(X) multiselect_op(Y) oneselect(Z).  {
   381    381     if( Z ){
   382    382       Z->op = Y;
   383    383       Z->pPrior = X;
          384  +  }else{
          385  +    sqlite3SelectDelete(X);
   384    386     }
   385    387     A = Z;
   386    388   }
   387    389   %type multiselect_op {int}
   388    390   multiselect_op(A) ::= UNION(OP).             {A = @OP;}
   389    391   multiselect_op(A) ::= UNION ALL.             {A = TK_ALL;}
   390    392   multiselect_op(A) ::= EXCEPT|INTERSECT(OP).  {A = @OP;}

Changes to test/fuzz_malloc.test.

     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   #
    13     13   # This file tests malloc failures in concert with fuzzy SQL generation.
    14     14   #
    15         -# $Id: fuzz_malloc.test,v 1.3 2007/06/15 13:57:20 drh Exp $
           15  +# $Id: fuzz_malloc.test,v 1.4 2007/06/15 17:03:15 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Only run these tests if memory debugging is turned on.
    21     21   #
    22     22   if {[info command sqlite_malloc_stat]==""} {
    23     23     puts "Skipping fuzz_malloc tests: not compiled with -DSQLITE_MEMDEBUG=1"
    24     24     finish_test
    25     25     return
    26     26   }
    27     27   
    28         -
    29     28   source $testdir/fuzz_common.tcl
    30     29   source $testdir/malloc_common.tcl
    31     30   
    32         -set ::REPEATS 20
           31  +set ::REPEATS 40
    33     32   
    34     33   #
    35     34   # Usage: do_fuzzy_malloc_test <testname> ?<options>?
    36     35   # 
    37     36   #     -template
    38     37   #     -sqlprep
    39     38   #     -repeats
................................................................................
    45     44   
    46     45     sqlite_malloc_fail 0
    47     46     db close
    48     47     file delete test.db test.db-journal
    49     48     sqlite3 db test.db
    50     49     set ::prep $::fuzzyopts(-sqlprep)
    51     50     execsql $::prep
    52         -
           51  +  set jj 0
    53     52     for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
           53  +    expr srand($jj)
           54  +    incr jj
    54     55       set ::sql [subst $::fuzzyopts(-template)]
    55     56       foreach {rc res} [catchsql "$::sql"] {}
    56     57       if {$rc==0} {
    57     58         do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep
    58     59       } else {
    59     60         incr ii -1
    60     61       }