Yuriy Kaminskiy wrote:
> Richard Hipp wrote:
>> On Thu, Feb 23, 2012 at 12:29 PM, Petite Abeille
>> <[email protected]>wrote:
>>
>>> On Feb 23, 2012, at 6:21 PM, Levi Haskell wrote:
>>>
>>>> sqlite> select 1 from (select *);
>>> Wow, wicked :)
>>>
>>> Confirmed on sqlite3 -version
>>> 3.7.10 2012-01-16 13:28:40 ebd01a8deffb5024a5d7494eef800d2366d97204
>>>
>>
>> Fixed here: http://www.sqlite.org/src/info/c8c7846fb9
>
> This fix triggers SQLITE_NOMEM and test/select1.test select1-16.1 failure when
> lookaside allocation failed (or sqlite compiled with SQLITE_OMIT_LOOKASIDE):
>> select1-16.1...
>> Expected: [1 {no tables specified}]
>> Got: [1 {out of memory}]
> Maybe sqlite3Malloc() should be changed to NOT return NULL when called with
> n==0.
Conservative fix:
Index: sqlite3-3.7.11/src/select.c
===================================================================
--- sqlite3-3.7.11.orig/src/select.c 2012-03-31 12:32:12.000000000 +0400
+++ sqlite3-3.7.11/src/select.c 2012-03-31 12:34:42.000000000 +0400
@@ -1258,7 +1258,11 @@ static int selectColumnsFromExprList(
char *zName; /* Column name */
int nName; /* Size of name in zName[] */
- *pnCol = nCol = pEList ? pEList->nExpr : 0;
+ if( !pEList ){
+ *pnCol = 0; *paCol = NULL;
+ return SQLITE_OK;
+ }
+ *pnCol = nCol = pEList->nExpr;
aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
if( aCol==0 ) return SQLITE_NOMEM;
for(i=0, pCol=aCol; i<nCol; i++, pCol++){
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users