mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix segfaults that can occur if a malloc failure happens just before
a built-in function calls sqlite3_value_text(). (CVS 3874) FossilOrigin-Name: 9cb0ed6ee9827bc6884a0195044d5b6ad0de698e
This commit is contained in:
13
src/date.c
13
src/date.c
@@ -16,7 +16,7 @@
|
||||
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: date.c,v 1.62 2007/04/06 02:32:34 drh Exp $
|
||||
** $Id: date.c,v 1.63 2007/04/25 18:23:53 drh Exp $
|
||||
**
|
||||
** NOTES:
|
||||
**
|
||||
@@ -655,12 +655,15 @@ static int parseModifier(const char *zMod, DateTime *p){
|
||||
*/
|
||||
static int isDate(int argc, sqlite3_value **argv, DateTime *p){
|
||||
int i;
|
||||
const unsigned char *z;
|
||||
if( argc==0 ) return 1;
|
||||
if( SQLITE_NULL==sqlite3_value_type(argv[0]) ||
|
||||
parseDateOrTime((char*)sqlite3_value_text(argv[0]), p) ) return 1;
|
||||
if( (z = sqlite3_value_text(argv[0]))==0 || parseDateOrTime((char*)z, p) ){
|
||||
return 1;
|
||||
}
|
||||
for(i=1; i<argc; i++){
|
||||
if( SQLITE_NULL==sqlite3_value_type(argv[i]) ||
|
||||
parseModifier((char*)sqlite3_value_text(argv[i]), p) ) return 1;
|
||||
if( (z = sqlite3_value_text(argv[i]))==0 || parseModifier((char*)z, p) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user