/ Check-in [2d2c53e5]
Login

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

Overview
Comment:Do not references zSql(-1) if nBytes==0 in sqlite3_prepare(). Ticket #3134. (CVS 5155)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2d2c53e5058412a5f484ac2ca5bcef596aed2a7b
User & Date: drh 2008-05-23 14:32:19
Context
2008-05-23
14:49
Add a test case of preparing a statement with an nBytes parameter of 0 and where the previous byte of the string is zero. Ticket #3134. (CVS 5156) check-in: 846a69ac user: drh tags: trunk
14:32
Do not references zSql(-1) if nBytes==0 in sqlite3_prepare(). Ticket #3134. (CVS 5155) check-in: 2d2c53e5 user: drh tags: trunk
2008-05-22
13:56
Ensure that the db.mallocFailed flag is cleared before sqlite3_errmsg16() returns. (CVS 5154) check-in: 0d47653a user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.84 2008/05/22 13:56:17 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
................................................................................
        return sqlite3ApiExit(db, SQLITE_LOCKED);
      }
    }
  }
  
  memset(&sParse, 0, sizeof(sParse));
  sParse.db = db;
  if( nBytes>=0 && zSql[nBytes-1]!=0 ){
    char *zSqlCopy;
    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
    if( nBytes>mxLen ){
      sqlite3Error(db, SQLITE_TOOBIG, "statement too long");
      (void)sqlite3SafetyOff(db);
      return sqlite3ApiExit(db, SQLITE_TOOBIG);
    }







|







 







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.85 2008/05/23 14:32:19 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Fill the InitData structure with an error message that indicates
** that the database is corrupt.
................................................................................
        return sqlite3ApiExit(db, SQLITE_LOCKED);
      }
    }
  }
  
  memset(&sParse, 0, sizeof(sParse));
  sParse.db = db;
  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
    char *zSqlCopy;
    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
    if( nBytes>mxLen ){
      sqlite3Error(db, SQLITE_TOOBIG, "statement too long");
      (void)sqlite3SafetyOff(db);
      return sqlite3ApiExit(db, SQLITE_TOOBIG);
    }