/ Check-in [e8b87bd4]
Login

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

Overview
Comment:Fix segfault in 'eval.c' extension when used with 'empty_result_callbacks'.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e8b87bd4954437041139344d6d1ce3e4aace40ea6891b70f9c20cd95671270e7
User & Date: mistachkin 2018-04-04 12:21:33
Context
2018-04-05
12:02
Fix the sqlite3WhereTrace mechanism so that it compiles with the --disable-amalgamation and the --enable-debug options to ./configure using clang. check-in: 81322436 user: drh tags: trunk
2018-04-04
12:21
Fix segfault in 'eval.c' extension when used with 'empty_result_callbacks'. check-in: e8b87bd4 user: mistachkin tags: trunk
2018-04-03
20:44
Fix an error message in speedtest1.c and make the "trigger" testset sensitive to the --size parameter. check-in: 5a6fd9e0 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/eval.c.

30
31
32
33
34
35
36

37
38
39
40
41
42
43

/*
** Callback from sqlite_exec() for the eval() function.
*/
static int callback(void *pCtx, int argc, char **argv, char **colnames){
  struct EvalResult *p = (struct EvalResult*)pCtx;
  int i; 

  for(i=0; i<argc; i++){
    const char *z = argv[i] ? argv[i] : "";
    size_t sz = strlen(z);
    if( (sqlite3_int64)sz+p->nUsed+p->szSep+1 > p->nAlloc ){
      char *zNew;
      p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1;
      /* Using sqlite3_realloc64() would be better, but it is a recent







>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

/*
** Callback from sqlite_exec() for the eval() function.
*/
static int callback(void *pCtx, int argc, char **argv, char **colnames){
  struct EvalResult *p = (struct EvalResult*)pCtx;
  int i; 
  if( argv==0 ) return 0;
  for(i=0; i<argc; i++){
    const char *z = argv[i] ? argv[i] : "";
    size_t sz = strlen(z);
    if( (sqlite3_int64)sz+p->nUsed+p->szSep+1 > p->nAlloc ){
      char *zNew;
      p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1;
      /* Using sqlite3_realloc64() would be better, but it is a recent

Changes to test/misc8.test.

53
54
55
56
57
58
59




60
61
62
63
64
65
66
  BEGIN;
  CREATE TABLE t2(x);
  SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam''')), c
    FROM t1
   ORDER BY rowid;
} {1 {abort due to ROLLBACK}}






reset_db

proc dbeval {sql} { db eval $sql }
db func eval dbeval

do_execsql_test misc8-2.1 {







>
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  BEGIN;
  CREATE TABLE t2(x);
  SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam''')), c
    FROM t1
   ORDER BY rowid;
} {1 {abort due to ROLLBACK}}

do_catchsql_test misc8-1.8 {
  PRAGMA empty_result_callbacks = 1;
  SELECT eval('SELECT * FROM t1 WHERE 1 = 0;');
} {0 {{}}}

reset_db

proc dbeval {sql} { db eval $sql }
db func eval dbeval

do_execsql_test misc8-2.1 {