From 011cfca18e23b6b5d34837ef8deab40d1a52800b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Aug 2009 15:56:51 +0000 Subject: [PATCH] Initialize variables differently in the range processing logic of where.c in order to make sure variables are always initialized even following an OOM error. FossilOrigin-Name: 3fb3686a4502140720dc3710a28a4f4128ab6554 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/where.c | 11 ++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index b8d4ba503a..71022e972c 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Attempt\sto\sclarify\sthe\smeaning\sof\sa\s"parameter"\sin\sthe\ssqlite3_bind()\sAPI\ndocumentation. -D 2009-08-25T14:59:37 +C Initialize\svariables\sdifferently\sin\sthe\srange\sprocessing\slogic\sof\swhere.c\nin\sorder\sto\smake\ssure\svariables\sare\salways\sinitialized\seven\sfollowing\nan\sOOM\serror. +D 2009-08-25T15:56:51 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -216,7 +216,7 @@ F src/vdbeblob.c a3f3e0e877fc64ea50165eec2855f5ada4477611 F src/vdbemem.c c4a5188ff43692f2ca78d3539ad4877e14b70712 F src/vtab.c aedd76e8670d5a5379f93804398d3ba960125547 F src/walker.c 1edca756275f158b80f20eb6f104c8d3fcc96a04 -F src/where.c b9ad2d2db4a7d1cda7bed8a7299eb73fde63b5b1 +F src/where.c fc8b33fb469d30c2d933188757ed4d71a775b08a F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -750,14 +750,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 -P 6a623e6cf0370456232497a84366d18fa180debb -R fcbb968e51afd78ed3c075342c97e2d1 +P 9389e6a7dad7ba70923282d6fe45fbccd22f681e +R ba5f45894b6fc316b385ccdbc215e894 U drh -Z f375ffcba1ac2c7cffa691451e61067e +Z 903cfcbc615b7cc03024df17088e7120 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFKk/xjoxKgR168RlERAsnbAJ4wPmuxVLQB8GdAW14JVlkINUJ5QwCfYUBz -gzYdveWl3zj0kWAvApoKFIs= -=Gtjj +iD8DBQFKlAnGoxKgR168RlERAsoLAJ4nH/YFuFnXcU6+a92QUZwF2QQ4ZACeLbl5 +hSBe5ozIRkuFFcem6hDzev0= +=C0Ud -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index b02765030a..7c355b3eaf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9389e6a7dad7ba70923282d6fe45fbccd22f681e \ No newline at end of file +3fb3686a4502140720dc3710a28a4f4128ab6554 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 8363241562..ba4cb8072c 100644 --- a/src/where.c +++ b/src/where.c @@ -2038,8 +2038,8 @@ static int whereRangeScanEst( if( nEq==0 && p->aSample ){ int iEst; - int iUpper; - int iLower; + int iLower = 0; + int iUpper = SQLITE_INDEX_SAMPLES; u8 aff = p->pTable->aCol[0].affinity; if( pLower ){ @@ -2057,17 +2057,14 @@ static int whereRangeScanEst( goto range_est_fallback; }else if( pLowerVal==0 ){ rc = whereRangeRegion(pParse, p, pUpperVal, &iUpper); - iLower = pLower ? iUpper/2 : 0; + if( pLower ) iLower = iUpper/2; }else if( pUpperVal==0 ){ rc = whereRangeRegion(pParse, p, pLowerVal, &iLower); - iUpper = pUpper ? (iLower + SQLITE_INDEX_SAMPLES + 1)/2 - : SQLITE_INDEX_SAMPLES; + if( pUpper ) iUpper = (iLower + SQLITE_INDEX_SAMPLES + 1)/2; }else{ rc = whereRangeRegion(pParse, p, pUpperVal, &iUpper); if( rc==SQLITE_OK ){ rc = whereRangeRegion(pParse, p, pLowerVal, &iLower); - }else{ - iLower = 0; } }