/ Check-in [29145746]
Login

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

Overview
Comment:Fix a bug in the OP_MemStore operator of the VDBE. A realloc() might occur but pointer to the old buffer were not being moved over to the new buffer. (CVS 752)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 29145746f34438bd830c763872c5e82572150357
User & Date: drh 2002-09-17 03:20:46
Context
2002-09-21
15:57
Make sure memory malloced() for structures is aligned on an even byte boundry. Solaris segfaults otherwise. (CVS 753) check-in: 14ebe30b user: drh tags: trunk
2002-09-17
03:20
Fix a bug in the OP_MemStore operator of the VDBE. A realloc() might occur but pointer to the old buffer were not being moved over to the new buffer. (CVS 752) check-in: 29145746 user: drh tags: trunk
2002-09-16
11:44
Modify the sqlite_encode_binary() routine to return the strlen() of the encoded string. Also fix a bug that occurs when attempting to encode a zero-length buffer. (CVS 751) check-in: f12c3a25 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    32     32   **
    33     33   ** Various scripts scan this source file in order to generate HTML
    34     34   ** documentation, headers files, or other derived files.  The formatting
    35     35   ** of the code in this file is, therefore, important.  See other comments
    36     36   ** in this file for details.  If in doubt, do not deviate from existing
    37     37   ** commenting and indentation practices when changing or adding code.
    38     38   **
    39         -** $Id: vdbe.c,v 1.178 2002/09/14 13:47:32 drh Exp $
           39  +** $Id: vdbe.c,v 1.179 2002/09/17 03:20:46 drh Exp $
    40     40   */
    41     41   #include "sqliteInt.h"
    42     42   #include <ctype.h>
    43     43   
    44     44   /*
    45     45   ** The makefile scans this source file and creates the following
    46     46   ** array of string constants which are the names of all VDBE opcodes.
................................................................................
  4755   4755     VERIFY( if( tos<0 ) goto not_enough_stack; )
  4756   4756     if( i>=p->nMem ){
  4757   4757       int nOld = p->nMem;
  4758   4758       Mem *aMem;
  4759   4759       p->nMem = i + 5;
  4760   4760       aMem = sqliteRealloc(p->aMem, p->nMem*sizeof(p->aMem[0]));
  4761   4761       if( aMem==0 ) goto no_mem;
         4762  +    if( aMem!=p->aMem ){
         4763  +      int j;
         4764  +      for(j=0; j<nOld; j++){
         4765  +        if( aMem[j].z==p->aMem[j].s.z ){
         4766  +          aMem[j].z = aMem[j].s.z;
         4767  +        }
         4768  +      }
         4769  +    }
  4762   4770       p->aMem = aMem;
  4763   4771       if( nOld<p->nMem ){
  4764   4772         memset(&p->aMem[nOld], 0, sizeof(p->aMem[0])*(p->nMem-nOld));
  4765   4773       }
  4766   4774     }
  4767   4775     pMem = &p->aMem[i];
  4768   4776     if( pMem->s.flags & STK_Dyn ){

Changes to test/misc1.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc1.test,v 1.14 2002/08/18 22:41:22 drh Exp $
           16  +# $Id: misc1.test,v 1.15 2002/09/17 03:20:46 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Test the creation and use of tables that have a large number
    22     22   # of columns.
    23     23   #
................................................................................
   394    394   } {1 4 4}
   395    395   do_test misc1-12.13 {
   396    396     execsql {
   397    397       SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1;
   398    398     }
   399    399   } {1 2 2 3 4 2}
   400    400   
   401         -
          401  +# There was a problem with realloc() in the OP_MemStore operation of
          402  +# the VDBE.  A buffer was being reallocated but some pointers into 
          403  +# the old copy of the buffer were not being moved over to the new copy.
          404  +# The following code tests for the problem.
          405  +#
          406  +do_test misc1-13.1 {
          407  +   execsql {
          408  +     CREATE TABLE t9(x,y);
          409  +     INSERT INTO t9 VALUES('one',1);
          410  +     INSERT INTO t9 VALUES('two',2);
          411  +     INSERT INTO t9 VALUES('three',3);
          412  +     INSERT INTO t9 VALUES('four',4);
          413  +     INSERT INTO t9 VALUES('five',5);
          414  +     INSERT INTO t9 VALUES('six',6);
          415  +     INSERT INTO t9 VALUES('seven',7);
          416  +     INSERT INTO t9 VALUES('eight',8);
          417  +     INSERT INTO t9 VALUES('nine',9);
          418  +     INSERT INTO t9 VALUES('ten',10);
          419  +     INSERT INTO t9 VALUES('eleven',11);
          420  +     SELECT y FROM t9
          421  +     WHERE x=(SELECT x FROM t9 WHERE y=1)
          422  +        OR x=(SELECT x FROM t9 WHERE y=2)
          423  +        OR x=(SELECT x FROM t9 WHERE y=3)
          424  +        OR x=(SELECT x FROM t9 WHERE y=4)
          425  +        OR x=(SELECT x FROM t9 WHERE y=5)
          426  +        OR x=(SELECT x FROM t9 WHERE y=6)
          427  +        OR x=(SELECT x FROM t9 WHERE y=7)
          428  +        OR x=(SELECT x FROM t9 WHERE y=8)
          429  +        OR x=(SELECT x FROM t9 WHERE y=9)
          430  +        OR x=(SELECT x FROM t9 WHERE y=10)
          431  +        OR x=(SELECT x FROM t9 WHERE y=11)
          432  +        OR x=(SELECT x FROM t9 WHERE y=12)
          433  +        OR x=(SELECT x FROM t9 WHERE y=13)
          434  +        OR x=(SELECT x FROM t9 WHERE y=14)
          435  +     ;
          436  +   }
          437  +} {1 2 3 4 5 6 7 8 9 10 11}
   402    438   
   403    439   finish_test