/ Check-in [acf26cc0]
Login

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

Overview
Comment:Avoid a segfault when OOM on a simple EXPLAIN query. Ticket #3478. (CVS 5860)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: acf26cc0f77b3a308d86f6dc02ecda66a4b12fd0
User & Date: drh 2008-11-04 14:25:06
Context
2008-11-04
14:48
Enhance documentation of sqlite3_db_mutex(). (CVS 5861) check-in: 3aed410a user: drh tags: trunk
14:25
Avoid a segfault when OOM on a simple EXPLAIN query. Ticket #3478. (CVS 5860) check-in: acf26cc0 user: drh tags: trunk
13:46
Add the sqlite3_db_mutex() interface. No test cases yet. (CVS 5859) check-in: d95de32e user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
**
*************************************************************************
** This file contains code used for creating, destroying, and populating
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.415 2008/11/03 20:55:07 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"



................................................................................
  */
  if( p->aMem==0 ){
    int nArg;       /* Maximum number of args passed to a user function. */
    resolveP2Values(p, &nArg);
    /*resizeOpArray(p, p->nOp);*/
    assert( nVar>=0 );
    if( isExplain && nMem<10 ){
      p->nMem = nMem = 10;
    }
    p->aMem = sqlite3DbMallocZero(db,
        nMem*sizeof(Mem)               /* aMem */
      + nVar*sizeof(Mem)               /* aVar */
      + nArg*sizeof(Mem*)              /* apArg */
      + nVar*sizeof(char*)             /* azVar */
      + nCursor*sizeof(VdbeCursor*)+1  /* apCsr */







|







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
**
*************************************************************************
** This file contains code used for creating, destroying, and populating
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.416 2008/11/04 14:25:06 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include "vdbeInt.h"



................................................................................
  */
  if( p->aMem==0 ){
    int nArg;       /* Maximum number of args passed to a user function. */
    resolveP2Values(p, &nArg);
    /*resizeOpArray(p, p->nOp);*/
    assert( nVar>=0 );
    if( isExplain && nMem<10 ){
      nMem = 10;
    }
    p->aMem = sqlite3DbMallocZero(db,
        nMem*sizeof(Mem)               /* aMem */
      + nVar*sizeof(Mem)               /* aVar */
      + nArg*sizeof(Mem*)              /* apArg */
      + nVar*sizeof(char*)             /* azVar */
      + nCursor*sizeof(VdbeCursor*)+1  /* apCsr */

Changes to test/mallocJ.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
44
45
46
47
48
49
50
51





52
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This test script checks malloc failures in LIMIT operations for 
# UPDATE/DELETE statements.
# 
# $Id: mallocJ.test,v 1.2 2008/10/30 22:13:23 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl

ifcapable {update_delete_limit} {

................................................................................
  INSERT INTO t1 VALUES(1,2);
} -sqlbody {
  SELECT a, b, 'abc' FROM t1
    UNION
    SELECT b, a, 'xyz' FROM t1
    ORDER BY 2, 3;
}






finish_test







|







 








>
>
>
>
>

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This test script checks malloc failures in LIMIT operations for 
# UPDATE/DELETE statements.
# 
# $Id: mallocJ.test,v 1.3 2008/11/04 14:25:06 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl

ifcapable {update_delete_limit} {

................................................................................
  INSERT INTO t1 VALUES(1,2);
} -sqlbody {
  SELECT a, b, 'abc' FROM t1
    UNION
    SELECT b, a, 'xyz' FROM t1
    ORDER BY 2, 3;
}

# ticket #3478
do_malloc_test mallocJ-3 -sqlbody {
  EXPLAIN COMMIT
}

finish_test