/ Check-in [739b5d9a]
Login

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

Overview
Comment:Avoid trying to allocate a negative number of bytes of memory in the test wrapper for sqlite3_blob_read().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 739b5d9aa4eaa4191ca512d0dbf94a6bdbb12d97
User & Date: dan 2010-10-27 19:08:26
Context
2010-10-28
11:31
Enforce the MAX_EXPR_DEPTH limit while building expression trees during SQL parsing. check-in: 2625eee0 user: dan tags: trunk
2010-10-27
19:23
Add tail recursion to the sqlite3ExprDelete() routine in order to keep down stack space usage for really, really large expressions. Later: The tail recursion is dangerous since the recursion might happen after the expression has been freed. check-in: 7324c7f2 user: drh tags: mistake
19:08
Avoid trying to allocate a negative number of bytes of memory in the test wrapper for sqlite3_blob_read(). check-in: 739b5d9a user: dan tags: trunk
18:10
Merge experimental fts3/fts4 changes with trunk. check-in: 988164cf user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test1.c.

  1686   1686     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  1687   1687     int objc,              /* Number of arguments */
  1688   1688     Tcl_Obj *CONST objv[]  /* Command arguments */
  1689   1689   ){
  1690   1690     sqlite3_blob *pBlob;
  1691   1691     int nByte;
  1692   1692     int iOffset;
  1693         -  unsigned char *zBuf;
         1693  +  unsigned char *zBuf = 0;
  1694   1694     int rc;
  1695   1695     
  1696   1696     if( objc!=4 ){
  1697   1697       Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL OFFSET N");
  1698   1698       return TCL_ERROR;
  1699   1699     }
  1700   1700   
................................................................................
  1701   1701     if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
  1702   1702     if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset)
  1703   1703      || TCL_OK!=Tcl_GetIntFromObj(interp, objv[3], &nByte)
  1704   1704     ){ 
  1705   1705       return TCL_ERROR;
  1706   1706     }
  1707   1707   
  1708         -  zBuf = (unsigned char *)Tcl_Alloc(nByte);
         1708  +  if( nByte>0 ){
         1709  +    zBuf = (unsigned char *)Tcl_Alloc(nByte);
         1710  +  }
  1709   1711     rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset);
  1710   1712     if( rc==SQLITE_OK ){
  1711   1713       Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zBuf, nByte));
  1712   1714     }else{
  1713   1715       Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
  1714   1716     }
  1715   1717     Tcl_Free((char *)zBuf);