From d797a9b5cb22e248015aabf0148ca544a7a7da3d Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 16:43:44 +0000 Subject: [PATCH 1/8] Changes to avoid obscure, theoretical undefined behavior. This is preventative measures only - no actual problems observed on tested compilers. FossilOrigin-Name: a9e819082ba19e72db03bba37edfb7702ff489a5 --- manifest | 18 +++++++-------- manifest.uuid | 2 +- src/printf.c | 2 +- src/test1.c | 4 ++-- src/test_malloc.c | 3 ++- src/vdbeaux.c | 58 ++++++++++++++++++++++++----------------------- 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index 00191f9fd0..35182fc887 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sdependence\son\s"exec\sls\s-U"\sfrom\sthe\svtabH.test\smodule,\sas\sthe\s-U\noption\sto\s"ls"\sis\snot\suniversally\savailable. -D 2015-12-04T13:44:07.797 +C Changes\sto\savoid\sobscure,\stheoretical\sundefined\sbehavior.\sThis\sis\spreventative\nmeasures\sonly\s-\sno\sactual\sproblems\sobserved\son\stested\scompilers. +D 2015-12-07T16:43:44.102 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -335,7 +335,7 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb +F src/printf.c 9a9105464fbbdf84b81fb902f2eaf1f771896af1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -349,7 +349,7 @@ F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 -F src/test1.c 4004bcc1b3b361a9137acd1d875599ecbdd6f961 +F src/test1.c 90c4e80c7f4b0ad82c6dbe699c8f430b641769f5 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -374,7 +374,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 -F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744 +F src/test_malloc.c 96df9381a1ff1f6d3805ff7231b9baf1386aaabf F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 9a234c9aaab4ad725daf94667cfed441a437c52d +F src/vdbeaux.c f7a3e80d96e0e383bf5b636bbb770d452f52cea2 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 042738ad3b769ad70fd7603f928d5b94a952267d -R d4a001dfc820878042f471ef37d7e668 +P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be +R 52003d35f295f961555bc017c6dea8be U drh -Z 2a98a6e0179300d3f1024c7c0c5f05bd +Z df68b9901f4a3c159da303c7427e83e3 diff --git a/manifest.uuid b/manifest.uuid index b3054dd7aa..72ed16cea5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ecbc75b465533cf80e166a9d0879b9afd3fe2be \ No newline at end of file +a9e819082ba19e72db03bba37edfb7702ff489a5 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 88bb82e3e3..e34ddd3bde 100644 --- a/src/printf.c +++ b/src/printf.c @@ -788,7 +788,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); - if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); + if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); }else{ diff --git a/src/test1.c b/src/test1.c index 186e4e4684..b8154a64fe 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5906,13 +5906,13 @@ static int test_sqlite3_log( Tcl_DecrRefCount(logcallback.pObj); logcallback.pObj = 0; logcallback.pInterp = 0; - sqlite3_config(SQLITE_CONFIG_LOG, 0, 0); + sqlite3_config(SQLITE_CONFIG_LOG, (void*)0, (void*)0); } if( objc>1 ){ logcallback.pObj = objv[1]; Tcl_IncrRefCount(logcallback.pObj); logcallback.pInterp = interp; - sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, 0); + sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, (void*)0); } return TCL_OK; } diff --git a/src/test_malloc.c b/src/test_malloc.c index a3ff9d205b..aaa640b03a 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -222,7 +222,8 @@ static int faultsimInstall(int install){ assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 ); rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m); - sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0); + sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, + (void*)0, (void*)0); } if( rc==SQLITE_OK ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1889aec79f..acf3864280 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1725,30 +1725,31 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){ ** ** nByte is the number of bytes of space needed. ** -** *ppFrom points to available space and pEnd points to the end of the -** available space. When space is allocated, *ppFrom is advanced past -** the end of the allocated space. +** pFrom points to *pnFrom bytes of available space. New space is allocated +** from the end of the pFrom buffer and *pnFrom is decremented. ** -** *pnByte is a counter of the number of bytes of space that have failed -** to allocate. If there is insufficient space in *ppFrom to satisfy the -** request, then increment *pnByte by the amount of the request. +** *pnNeeded is a counter of the number of bytes of space that have failed +** to allocate. If there is insufficient space in pFrom to satisfy the +** request, then increment *pnNeeded by the amount of the request. */ static void *allocSpace( void *pBuf, /* Where return pointer will be stored */ int nByte, /* Number of bytes to allocate */ - u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ - u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ - int *pnByte /* If allocation cannot be made, increment *pnByte */ + u8 *pFrom, /* Memory available for allocation */ + int *pnFrom, /* IN/OUT: Space available at pFrom */ + int *pnNeeded /* If allocation cannot be made, increment *pnByte */ ){ - assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); - if( pBuf ) return pBuf; - nByte = ROUND8(nByte); - if( &(*ppFrom)[nByte] <= pEnd ){ - pBuf = (void*)*ppFrom; - *ppFrom += nByte; - }else{ - *pnByte += nByte; + assert( EIGHT_BYTE_ALIGNMENT(pFrom) ); + if( pBuf==0 ){ + nByte = ROUND8(nByte); + if( nByte <= *pnFrom ){ + *pnFrom -= nByte; + pBuf = &pFrom[*pnFrom]; + }else{ + *pnNeeded += nByte; + } } + assert( EIGHT_BYTE_ALIGNMENT(pBuf) ); return pBuf; } @@ -1821,8 +1822,8 @@ void sqlite3VdbeMakeReady( int nArg; /* Number of arguments in subprograms */ int nOnce; /* Number of OP_Once instructions */ int n; /* Loop counter */ + int nFree; /* Available free space */ u8 *zCsr; /* Memory available for allocation */ - u8 *zEnd; /* First byte past allocated memory */ int nByte; /* How much extra memory is needed */ assert( p!=0 ); @@ -1854,14 +1855,15 @@ void sqlite3VdbeMakeReady( ** an array to marshal SQL function arguments in. */ zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - zEnd = (u8*)&p->aOp[pParse->nOpAlloc]; /* First byte past end of zCsr[] */ + assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); + nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - memset(zCsr, 0, zEnd-zCsr); + memset(zCsr, 0, nFree); zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); p->expired = 0; @@ -1878,21 +1880,21 @@ void sqlite3VdbeMakeReady( */ do { nByte = 0; - p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); - p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte); - p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte); - p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte); + p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); + p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); + p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); + p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), - &zCsr, zEnd, &nByte); - p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte); + zCsr, &nFree, &nByte); + p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); #ifdef SQLITE_ENABLE_STMT_SCANSTATUS - p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte); + p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte); #endif if( nByte ){ p->pFree = sqlite3DbMallocZero(db, nByte); } zCsr = p->pFree; - zEnd = &zCsr[nByte]; + nFree = nByte; }while( nByte && !db->mallocFailed ); p->nCursor = nCursor; From dc27851e21a94a0200bace098f61ec6deb4b427a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 18:18:33 +0000 Subject: [PATCH 2/8] Fix the openDirectory() routine in the unix VFS so that it works for databases located in the root of the filesystem and for database files that have no pathname at all. FossilOrigin-Name: e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 35182fc887..1054bbef33 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\savoid\sobscure,\stheoretical\sundefined\sbehavior.\sThis\sis\spreventative\nmeasures\sonly\s-\sno\sactual\sproblems\sobserved\son\stested\scompilers. -D 2015-12-07T16:43:44.102 +C Fix\sthe\sopenDirectory()\sroutine\sin\sthe\sunix\sVFS\sso\sthat\sit\sworks\sfor\sdatabases\nlocated\sin\sthe\sroot\sof\sthe\sfilesystem\sand\sfor\sdatabase\sfiles\sthat\shave\sno\npathname\sat\sall. +D 2015-12-07T18:18:33.086 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 2563734669b06432cea640cbb4f7e9d543f227b9 +F src/os_unix.c 0ca6d8710366fbb01a275160f018334cd347cbda F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be -R 52003d35f295f961555bc017c6dea8be +P a9e819082ba19e72db03bba37edfb7702ff489a5 +R 24074b14133d8cbad307bf1c20e69806 U drh -Z df68b9901f4a3c159da303c7427e83e3 +Z bce64672fed9a01eb65d3786fa37a9f1 diff --git a/manifest.uuid b/manifest.uuid index 72ed16cea5..dc8c28b89e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9e819082ba19e72db03bba37edfb7702ff489a5 \ No newline at end of file +e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index beaac0d15d..791ba5d8d9 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3465,13 +3465,16 @@ static int openDirectory(const char *zFilename, int *pFd){ char zDirname[MAX_PATHNAME+1]; sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); - for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); - if( ii>1 ){ + for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); + if( ii>0 ){ zDirname[ii] = '\0'; - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); - if( fd>=0 ){ - OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); - } + }else{ + if( zDirname[0]!='/' ) zDirname[0] = '.'; + zDirname[1] = 0; + } + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); + if( fd>=0 ){ + OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } *pFd = fd; if( fd>=0 ) return SQLITE_OK; From df12f1c69bad540de5036f99812a7e41ea377ddb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 21:46:19 +0000 Subject: [PATCH 3/8] Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for testing and verifying the sqlite3_changes() and sqlite3_total_changes() interfaces. FossilOrigin-Name: 9bbe1afc1521b111a0a93803b41ff04e0ee55630 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 1054bbef33..3a0b27394c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sopenDirectory()\sroutine\sin\sthe\sunix\sVFS\sso\sthat\sit\sworks\sfor\sdatabases\nlocated\sin\sthe\sroot\sof\sthe\sfilesystem\sand\sfor\sdatabase\sfiles\sthat\shave\sno\npathname\sat\sall. -D 2015-12-07T18:18:33.086 +C Add\sthe\s".changes\sON|OFF"\scommand\sto\sthe\ssqlite3.exe\scommand-line\sshell,\sfor\ntesting\sand\sverifying\sthe\ssqlite3_changes()\sand\nsqlite3_total_changes()\sinterfaces. +D 2015-12-07T21:46:19.114 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -340,7 +340,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 +F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a9e819082ba19e72db03bba37edfb7702ff489a5 -R 24074b14133d8cbad307bf1c20e69806 +P e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 +R 73237b31faf24d2547a2561196384a88 U drh -Z bce64672fed9a01eb65d3786fa37a9f1 +Z 44232263f2d956132c0ce354e853bbb1 diff --git a/manifest.uuid b/manifest.uuid index dc8c28b89e..65f5be92c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 \ No newline at end of file +9bbe1afc1521b111a0a93803b41ff04e0ee55630 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index bcad59e806..ff1336a4b7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -525,6 +525,7 @@ struct ShellState { int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ int statsOn; /* True to display memory stats before each finalize */ int scanstatsOn; /* True to display scan stats before each finalize */ + int countChanges; /* True to display change counts */ int backslashOn; /* Resolve C-style \x escapes in SQL input text */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ @@ -1785,6 +1786,7 @@ static char zHelp[] = ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" + ".changes on|off Show number of rows changed by SQL\n" ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" @@ -2757,6 +2759,15 @@ static int do_meta_command(char *zLine, ShellState *p){ test_breakpoint(); }else + if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){ + if( nArg==2 ){ + p->countChanges = booleanValue(azArg[1]); + }else{ + fprintf(stderr, "Usage: .changes on|off\n"); + rc = 1; + } + }else + if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){ if( nArg==2 ){ tryToClone(p, azArg[1]); @@ -4286,6 +4297,9 @@ static int process_input(ShellState *p, FILE *in){ fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; + }else if( p->countChanges ){ + fprintf(p->out, "changes: %3d total_changes: %d\n", + sqlite3_changes(p->db), sqlite3_total_changes(p->db)); } nSql = 0; if( p->outCount ){ From 855ed4a3b48f5bc08d42a4a331325a4e0518e4ba Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 7 Dec 2015 23:31:59 +0000 Subject: [PATCH 4/8] Update MSVC batch build tool to the latest Windows 10 SDK version. FossilOrigin-Name: 2ad5017190334b7dd53294a30c3b3232e0c35869 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/build-all-msvc.bat | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3a0b27394c..ee2b3ef82f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".changes\sON|OFF"\scommand\sto\sthe\ssqlite3.exe\scommand-line\sshell,\sfor\ntesting\sand\sverifying\sthe\ssqlite3_changes()\sand\nsqlite3_total_changes()\sinterfaces. -D 2015-12-07T21:46:19.114 +C Update\sMSVC\sbatch\sbuild\stool\sto\sthe\slatest\sWindows\s10\sSDK\sversion. +D 2015-12-07T23:31:59.191 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1350,7 +1350,7 @@ F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8606413d3035c05373a0d7fae82ebf59ae9e16c3 F tool/addopcodes.tcl 4ca9c3ef196f08da30add5d07ce0c9458dc8c633 -F tool/build-all-msvc.bat e42141ca3c3812315432f9813ef9eb78aa8d99c9 x +F tool/build-all-msvc.bat 204a039f985d5a4f4f9df3a3aa594fd17848c37e x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 -R 73237b31faf24d2547a2561196384a88 -U drh -Z 44232263f2d956132c0ce354e853bbb1 +P 9bbe1afc1521b111a0a93803b41ff04e0ee55630 +R 09e1a6b4b7c25190447a2783c034d72c +U mistachkin +Z e9b23e5e87abed46d08ef4a9e1279cbf diff --git a/manifest.uuid b/manifest.uuid index 65f5be92c9..0efcda5e92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bbe1afc1521b111a0a93803b41ff04e0ee55630 \ No newline at end of file +2ad5017190334b7dd53294a30c3b3232e0c35869 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index e081c73b38..87794132b6 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -320,7 +320,7 @@ REM IF DEFINED UCRTVersion ( SET NUCRTVER=%UCRTVersion% ) ELSE ( - SET NUCRTVER=10.0.10240.0 + SET NUCRTVER=10.0.10586.0 ) REM From a295d1521a94f0c0277d60c53f8bd058a3f94204 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 8 Dec 2015 00:47:32 +0000 Subject: [PATCH 5/8] Update the TclKit download URL. FossilOrigin-Name: 07e5199c6f868cc02a0b708865254056c4f3daf3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/GetTclKit.bat | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ee2b3ef82f..dac89710e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sMSVC\sbatch\sbuild\stool\sto\sthe\slatest\sWindows\s10\sSDK\sversion. -D 2015-12-07T23:31:59.191 +C Update\sthe\sTclKit\sdownload\sURL. +D 2015-12-08T00:47:32.597 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1348,7 +1348,7 @@ F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 -F tool/GetTclKit.bat 8606413d3035c05373a0d7fae82ebf59ae9e16c3 +F tool/GetTclKit.bat 629d87562e0487c386db630033931d12d62e6372 F tool/addopcodes.tcl 4ca9c3ef196f08da30add5d07ce0c9458dc8c633 F tool/build-all-msvc.bat 204a039f985d5a4f4f9df3a3aa594fd17848c37e x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9bbe1afc1521b111a0a93803b41ff04e0ee55630 -R 09e1a6b4b7c25190447a2783c034d72c +P 2ad5017190334b7dd53294a30c3b3232e0c35869 +R 3561bc5f3aaa22b7dbf4b237affa0cef U mistachkin -Z e9b23e5e87abed46d08ef4a9e1279cbf +Z 2e63742234f7b704fba2b32627d437ce diff --git a/manifest.uuid b/manifest.uuid index 0efcda5e92..0dd1181e30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ad5017190334b7dd53294a30c3b3232e0c35869 \ No newline at end of file +07e5199c6f868cc02a0b708865254056c4f3daf3 \ No newline at end of file diff --git a/tool/GetTclKit.bat b/tool/GetTclKit.bat index 1ed15ea7f3..84235cf97a 100644 --- a/tool/GetTclKit.bat +++ b/tool/GetTclKit.bat @@ -62,7 +62,7 @@ IF NOT DEFINED TEMP ( %_VECHO% Temp = '%TEMP%' IF NOT DEFINED TCLKIT_URI ( - SET TCLKIT_URI=http://tclsh.com/ + SET TCLKIT_URI=https://tclsh.com/ ) %_VECHO% TclKitUri = '%TCLKIT_URI%' From 92a82771498c19c39abaa3754ff0d307ad7da9dd Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 04:18:33 +0000 Subject: [PATCH 6/8] Add a test case of the form "WHERE a<2 OR a<3" using PRAGMA count_changes. This test case was failing before the 3.9.0 release. FossilOrigin-Name: 177862c1d50ba899d890fbc35f35e7423bc6aed5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/where7.test | 12 ++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index dac89710e1..d584f281f3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sTclKit\sdownload\sURL. -D 2015-12-08T00:47:32.597 +C Add\sa\stest\scase\sof\sthe\sform\s"WHERE\sa<2\sOR\sa<3"\susing\sPRAGMA\scount_changes.\nThis\stest\scase\swas\sfailing\sbefore\sthe\s3.9.0\srelease. +D 2015-12-08T04:18:33.696 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1314,7 +1314,7 @@ F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 +F test/where7.test f520bcec2c3d12dc4615623b06b2aec7c2d67e94 F test/where8.test 98eedca0d375fb400b8377269c4b4686582dfb45 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2ad5017190334b7dd53294a30c3b3232e0c35869 -R 3561bc5f3aaa22b7dbf4b237affa0cef -U mistachkin -Z 2e63742234f7b704fba2b32627d437ce +P 07e5199c6f868cc02a0b708865254056c4f3daf3 +R 17b34bcad46ec764b462c91813dd5909 +U drh +Z 86e126efc794a5aaf900005c30a5cf69 diff --git a/manifest.uuid b/manifest.uuid index 0dd1181e30..d39829dc75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07e5199c6f868cc02a0b708865254056c4f3daf3 \ No newline at end of file +177862c1d50ba899d890fbc35f35e7423bc6aed5 \ No newline at end of file diff --git a/test/where7.test b/test/where7.test index 5032c698b2..00cf5eb278 100644 --- a/test/where7.test +++ b/test/where7.test @@ -47,6 +47,18 @@ do_test where7-1.1 { SELECT * FROM t1; } } {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000} +do_execsql_test where7-1.1.1 { + CREATE TABLE t(a); + CREATE INDEX ta ON t(a); + INSERT INTO t(a) VALUES(1),(2); + SELECT * FROM t ORDER BY a; + SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a; + PRAGMA count_changes=ON; + DELETE FROM t WHERE a<2 OR a<3; + SELECT * FROM t; + PRAGMA count_changes=OFF; + DROP TABLE t; +} {1 2 1 2 2} do_test where7-1.2 { count_steps { SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a From ea06a271a4cfd530325c35a5a9ba00e185059bd2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 16:08:10 +0000 Subject: [PATCH 7/8] Avoid doing comparisons with pointers that might have been previously been passed to realloc() and/or free(). FossilOrigin-Name: f20396adb2cff12a17a3fc90b36241ae3fdfd62a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/printf.c | 17 +++++++++++++---- src/sqliteInt.h | 1 + 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index d584f281f3..0a0d901caa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sof\sthe\sform\s"WHERE\sa<2\sOR\sa<3"\susing\sPRAGMA\scount_changes.\nThis\stest\scase\swas\sfailing\sbefore\sthe\s3.9.0\srelease. -D 2015-12-08T04:18:33.696 +C Avoid\sdoing\scomparisons\swith\spointers\sthat\smight\shave\sbeen\spreviously\sbeen\npassed\sto\srealloc()\sand/or\sfree(). +D 2015-12-08T16:08:10.872 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -335,7 +335,7 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c 9a9105464fbbdf84b81fb902f2eaf1f771896af1 +F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -344,7 +344,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 +F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 07e5199c6f868cc02a0b708865254056c4f3daf3 -R 17b34bcad46ec764b462c91813dd5909 +P 177862c1d50ba899d890fbc35f35e7423bc6aed5 +R 428581991da630a9c7b367e41a5c2afb U drh -Z 86e126efc794a5aaf900005c30a5cf69 +Z 910de169aa0a3078fbedf4d83c3245e1 diff --git a/manifest.uuid b/manifest.uuid index d39829dc75..294312aa8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -177862c1d50ba899d890fbc35f35e7423bc6aed5 \ No newline at end of file +f20396adb2cff12a17a3fc90b36241ae3fdfd62a \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index e34ddd3bde..969950c154 100644 --- a/src/printf.c +++ b/src/printf.c @@ -766,8 +766,9 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ setStrAccumError(p, STRACCUM_TOOBIG); return N; }else{ - char *zOld = (p->zText==p->zBase ? 0 : p->zText); + char *zOld = p->bMalloced ? p->zText : 0; i64 szNew = p->nChar; + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ /* Force exponential buffer size growth as long as it does not overflow, @@ -788,9 +789,10 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); - if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); + if( !p->bMalloced && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); + p->bMalloced = 1; }else{ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_NOMEM); @@ -808,6 +810,7 @@ void sqlite3AppendChar(StrAccum *p, int N, char c){ if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; } + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); while( (N--)>0 ) p->zText[p->nChar++] = c; } @@ -825,6 +828,7 @@ static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){ memcpy(&p->zText[p->nChar], z, N); p->nChar += N; } + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); } /* @@ -860,11 +864,13 @@ void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){ */ char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); p->zText[p->nChar] = 0; - if( p->mxAlloc>0 && p->zText==p->zBase ){ + if( p->mxAlloc>0 && p->bMalloced==0 ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); + p->bMalloced = 1; }else{ setStrAccumError(p, STRACCUM_NOMEM); } @@ -877,8 +883,10 @@ char *sqlite3StrAccumFinish(StrAccum *p){ ** Reset an StrAccum string. Reclaim all malloced memory. */ void sqlite3StrAccumReset(StrAccum *p){ - if( p->zText!=p->zBase ){ + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); + if( p->bMalloced ){ sqlite3DbFree(p->db, p->zText); + p->bMalloced = 0; } p->zText = 0; } @@ -904,6 +912,7 @@ void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){ p->nAlloc = n; p->mxAlloc = mx; p->accError = 0; + p->bMalloced = 0; } /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 338a573253..0d477dc06f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2952,6 +2952,7 @@ struct StrAccum { int nAlloc; /* Amount of space allocated in zText */ int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ + u8 bMalloced; /* zText points to allocated space */ }; #define STRACCUM_NOMEM 1 #define STRACCUM_TOOBIG 2 From 72ea29d7ae7395c66869f6848d3af94c20843a72 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 16:58:45 +0000 Subject: [PATCH 8/8] Changes to avoid undefined behavior in memset() and memcpy() and in the comparisons of pointers from different allocations. All problems are found by analysis tools - none have been seen in the wild. FossilOrigin-Name: 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 5 +++++ src/expr.c | 6 +++++- src/vdbeaux.c | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0a0d901caa..4be65dcffd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sdoing\scomparisons\swith\spointers\sthat\smight\shave\sbeen\spreviously\sbeen\npassed\sto\srealloc()\sand/or\sfree(). -D 2015-12-08T16:08:10.872 +C Changes\sto\savoid\sundefined\sbehavior\sin\smemset()\sand\smemcpy()\sand\sin\sthe\ncomparisons\sof\spointers\sfrom\sdifferent\sallocations.\s\sAll\sproblems\sare\sfound\nby\sanalysis\stools\s-\snone\shave\sbeen\sseen\sin\sthe\swild. +D 2015-12-08T16:58:45.426 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -282,7 +282,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c d3bdd8462a86492e2ebc9aca4a0168429017de25 +F src/btree.c 81d041421359bbffc091c8a95dd0507aa4f09093 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b @@ -292,7 +292,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 +F src/expr.c ccb93d7b7e1ac5d187c9b153bae145933f93ee5c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c f7a3e80d96e0e383bf5b636bbb770d452f52cea2 +F src/vdbeaux.c 8405f7441cb75c5d1816d1731a041d450e9ff2e9 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 177862c1d50ba899d890fbc35f35e7423bc6aed5 -R 428581991da630a9c7b367e41a5c2afb +P f20396adb2cff12a17a3fc90b36241ae3fdfd62a +R 70bc46af51bec4fcd5f5ac34f7fbc9eb U drh -Z 910de169aa0a3078fbedf4d83c3245e1 +Z 9b6f69f2c38f1825e156d39e6c72b0a2 diff --git a/manifest.uuid b/manifest.uuid index 294312aa8e..a26e28b825 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f20396adb2cff12a17a3fc90b36241ae3fdfd62a \ No newline at end of file +901d0b8f3b72e96ffa8e9436993a12980f5ebd51 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4a51b01d75..34ce8c3592 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7521,8 +7521,13 @@ static int balance_nonroot( ** overflow cell), we can skip updating the pointer map entries. */ if( iOld>=nNew || pNew->pgno!=aPgno[iOld] +#ifdef HAVE_STDINT_H + || (intptr_t)pCell<(intptr_t)aOld + || (intptr_t)pCell>=(intptr_t)&aOld[usableSize] +#else || pCell=&aOld[usableSize] +#endif ){ if( !leafCorrection ){ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc); diff --git a/src/expr.c b/src/expr.c index 8cf018f9d4..8f6377e664 100644 --- a/src/expr.c +++ b/src/expr.c @@ -853,6 +853,7 @@ static int dupedExprSize(Expr *p, int flags){ */ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ Expr *pNew = 0; /* Value to return */ + assert( flags==0 || flags==EXPRDUP_REDUCE ); if( p ){ const int isReduced = (flags&EXPRDUP_REDUCE); u8 *zAlloc; @@ -889,7 +890,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ }else{ int nSize = exprStructSize(p); memcpy(zAlloc, p, nSize); - memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); + if( nSizen + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0) == (int)sqlite3VdbeSerialTypeLen(serial_type) ); len = pMem->n; - memcpy(buf, pMem->z, len); + if( len>0 ) memcpy(buf, pMem->z, len); return len; }