SQLite4
Check-in [24ee36b76f]
Not logged in

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

Overview
Comment:Fix defect in which sqlite4_num_from_text returns NaN if it uses exactly as many bytes as the caller allows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | num_work
Files: files | file ages | folders
SHA1: 24ee36b76f0772b140871a121213607267fe807b
User & Date: peterreid 2013-02-10 19:21:53
Context
2013-02-10
22:03
Add sqlite4_num_add/sub/mul/div to testfixture and some tests that use them. check-in: 91bfc9e7d7 user: peterreid tags: num_work
19:21
Fix defect in which sqlite4_num_from_text returns NaN if it uses exactly as many bytes as the caller allows. check-in: 24ee36b76f user: peterreid tags: num_work
04:26
Add a failing test and supporting functions. When the buffer is ended by a passed-in byte count instead of a trailing 0, sqlite4_num_from_text returns NaN check-in: 2cff3b428a user: peterreid tags: num_work
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/math.c.

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390



391
392

393
394
395
396
397
398
399
        if( seenRadix ) r.e--;
      }else{
        if( c!='0' ) r.approx = 1;
        if( !seenRadix ) r.e++;
      }
    }else if( c=='.' ){
      seenRadix = 1;
    }else{
      break;
    }
  }
  if( c=='e' || c=='E' ){
    int exp = 0;
    int expsign = 0;
    int nEDigit = 0;
    if( zIn[i]=='-' ){
      expsign = 1;
      i += incr;
    }else if( zIn[i]=='+' ){
      i += incr;
    }
    if( i>=nIn ) goto not_a_valid_number;
    while( i<nIn && (c = zIn[i])!=0  ){
      i += incr;
      if( c<'0' || c>'9' ) break;
      if( c=='0' && nEDigit==0 ) continue;
      nEDigit++;
      if( nEDigit>3 ) goto not_a_valid_number;
      exp = exp*10 + c - '0';
    }
    if( expsign ) exp = -exp;
    r.e += exp;



  }
  if( c!=0 ) goto not_a_valid_number;

  return r;
  
not_a_valid_number:
  r.e = SQLITE4_MX_EXP+1;
  r.m = 0;
  return r;  
}







<
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
<
>







359
360
361
362
363
364
365




366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390

391
392
393
394
395
396
397
398
        if( seenRadix ) r.e--;
      }else{
        if( c!='0' ) r.approx = 1;
        if( !seenRadix ) r.e++;
      }
    }else if( c=='.' ){
      seenRadix = 1;




    }else if( c=='e' || c=='E' ){
      int exp = 0;
      int expsign = 0;
      int nEDigit = 0;
      if( zIn[i]=='-' ){
        expsign = 1;
        i += incr;
      }else if( zIn[i]=='+' ){
        i += incr;
      }
      if( i>=nIn ) goto not_a_valid_number;
      while( i<nIn && (c = zIn[i])!=0 ){
        i += incr;
        if( c<'0' || c>'9' ) goto not_a_valid_number;
        if( c=='0' && nEDigit==0 ) continue;
        nEDigit++;
        if( nEDigit>3 ) goto not_a_valid_number;
        exp = exp*10 + c - '0';
      }
      if( expsign ) exp = -exp;
      r.e += exp;
      break;
    }else{
      goto not_a_valid_number;
    }

  }
  return r;
  
not_a_valid_number:
  r.e = SQLITE4_MX_EXP+1;
  r.m = 0;
  return r;  
}