/ Check-in [4becc47e]
Login

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

Overview
Comment:Avoid 32-bit integer overflow when evaluating the exponent of a floating point value during ascii to binary conversion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4becc47eb4d48686faca4f61e93e5f379b227fcc
User & Date: drh 2011-10-17 20:41:46
Context
2011-10-17
23:15
Change the OP_JournalMode implementation so that it works even if a substitute sqlite3PagerFilename() that might return NULL is used. check-in: 491ff5fb user: drh tags: trunk
20:41
Avoid 32-bit integer overflow when evaluating the exponent of a floating point value during ascii to binary conversion. check-in: 4becc47e user: drh tags: trunk
12:14
Performance improvement for ascii to floating-point conversions with very large exponents. check-in: 59bb999c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/util.c.

327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
      esign = -1;
      z+=incr;
    }else if( *z=='+' ){
      z+=incr;
    }
    /* copy digits to exponent */
    while( z<zEnd && sqlite3Isdigit(*z) ){
      e = e*10 + (*z - '0');
      z+=incr;
      eValid = 1;
    }
  }

  /* skip trailing spaces */
  if( nDigits && eValid ){







|







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
      esign = -1;
      z+=incr;
    }else if( *z=='+' ){
      z+=incr;
    }
    /* copy digits to exponent */
    while( z<zEnd && sqlite3Isdigit(*z) ){
      e = e<10000 ? (e*10 + (*z - '0')) : 10000;
      z+=incr;
      eValid = 1;
    }
  }

  /* skip trailing spaces */
  if( nDigits && eValid ){

Changes to test/nan.test.

315
316
317
318
319
320
321
322





323






324



































325

do_realnum_test nan-4.20 {
  db eval {DELETE FROM t1}
  set big [string repeat 9 10000].0e-9000
  db eval "INSERT INTO t1 VALUES($big)"
  db eval {SELECT x, typeof(x) FROM t1}
} {inf real}

















































finish_test








>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371

do_realnum_test nan-4.20 {
  db eval {DELETE FROM t1}
  set big [string repeat 9 10000].0e-9000
  db eval "INSERT INTO t1 VALUES($big)"
  db eval {SELECT x, typeof(x) FROM t1}
} {inf real}

do_realnum_test nan-4.30 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e+9999');
    SELECT x, typeof(x) FROM t1;
  }
} {inf real}
do_realnum_test nan-4.31 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e+10000');
    SELECT x, typeof(x) FROM t1;
  }
} {inf real}

do_realnum_test nan-4.32 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e-9999');
    SELECT x, typeof(x) FROM t1;
  }
} {0.0 real}
do_realnum_test nan-4.33 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e-10000');
    SELECT x, typeof(x) FROM t1;
  }
} {0.0 real}
do_realnum_test nan-4.34 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e2147483650');
    SELECT x, typeof(x) FROM t1;
  }
} {inf real}
do_realnum_test nan-4.35 {
  db eval {
    DELETE FROM t1;
    INSERT INTO t1 VALUES('2.5e-2147483650');
    SELECT x, typeof(x) FROM t1;
  }
} {0.0 real}

  



finish_test