/ Check-in [4afdf970]
Login

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

Overview
Comment:Avoid all memory allocation (and hence the possiblitity of OOM failure) in sqlite3_value_double() and sqlite3_column_double().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4afdf9705a7c2b67aea31c5d51b9c295867d62d1
User & Date: drh 2010-10-05 12:05:32
Context
2010-10-05
15:41
If walLockExclusive() fails for reasons other than SQLITE_BUSY inside of walRestartLog() then propagate that error back up to the application. check-in: 04dcba6b user: drh tags: trunk
12:05
Avoid all memory allocation (and hence the possiblitity of OOM failure) in sqlite3_value_double() and sqlite3_column_double(). check-in: 4afdf970 user: drh tags: trunk
11:33
Fix an assert() failing on OSX. check-in: dca87638 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
  if( pMem->flags & MEM_Real ){
    return pMem->r;
  }else if( pMem->flags & MEM_Int ){
    return (double)pMem->u.i;
  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
    double val = (double)0;
    pMem->flags |= MEM_Str;
    if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
       || sqlite3VdbeMemNulTerminate(pMem) ){
      /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
      return (double)0;
    }
    assert( pMem->z );
    sqlite3AtoF(pMem->z, &val, pMem->n, SQLITE_UTF8);
    return val;
  }else{
    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
    return (double)0;
  }
}








<
<
<
<
<
<
<
|







389
390
391
392
393
394
395







396
397
398
399
400
401
402
403
  if( pMem->flags & MEM_Real ){
    return pMem->r;
  }else if( pMem->flags & MEM_Int ){
    return (double)pMem->u.i;
  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
    double val = (double)0;







    sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
    return val;
  }else{
    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
    return (double)0;
  }
}