SQLite

Check-in [501b743bcb]
Login

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

Overview
Comment:Prevent a possible segfault when the sqlite3_value_numeric_type() interface is misused to try to determine the numeric type of the NULL value returned from sqlite3_column_value() with an invalid column number.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 501b743bcb60cda0acf63bcf8a4abbf00797b347
User & Date: drh 2010-11-18 12:31:24.000
Context
2010-11-18
13:47
Fix compiler warnings. (check-in: 6c4f1d5c24 user: drh tags: trunk)
12:31
Prevent a possible segfault when the sqlite3_value_numeric_type() interface is misused to try to determine the numeric type of the NULL value returned from sqlite3_column_value() with an invalid column number. (check-in: 501b743bcb user: drh tags: trunk)
2010-11-17
02:02
Restrict the scope of the sqlite3_stmt_readonly() interface to a specific subset of prepared statement types. (check-in: 919b06c3a8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
307
308
309
310
311
312
313
314
315
316
317
318

319
320

321
322
323
324
325
326
327
}

/*
** Try to convert the type of a function argument or a result column
** into a numeric representation.  Use either INTEGER or REAL whichever
** is appropriate.  But only do the conversion if it is possible without
** loss of information and return the revised type of the argument.
**
** This is an EXPERIMENTAL api and is subject to change or removal.
*/
int sqlite3_value_numeric_type(sqlite3_value *pVal){
  Mem *pMem = (Mem*)pVal;

  applyNumericAffinity(pMem);
  sqlite3VdbeMemStoreType(pMem);

  return pMem->type;
}

/*
** Exported version of applyAffinity(). This one works on sqlite3_value*, 
** not the internal Mem* type.
*/







<
<



>
|
|
>







307
308
309
310
311
312
313


314
315
316
317
318
319
320
321
322
323
324
325
326
327
}

/*
** Try to convert the type of a function argument or a result column
** into a numeric representation.  Use either INTEGER or REAL whichever
** is appropriate.  But only do the conversion if it is possible without
** loss of information and return the revised type of the argument.


*/
int sqlite3_value_numeric_type(sqlite3_value *pVal){
  Mem *pMem = (Mem*)pVal;
  if( pMem->type==SQLITE_TEXT ){
    applyNumericAffinity(pMem);
    sqlite3VdbeMemStoreType(pMem);
  }
  return pMem->type;
}

/*
** Exported version of applyAffinity(). This one works on sqlite3_value*, 
** not the internal Mem* type.
*/