Skip to content

Commit

Permalink
The strtol() method with a base of 0 treats leading zeroes as an octa…
Browse files Browse the repository at this point in the history
…l number,

which leads to corruption of numbers like 1e-08 and 1e-09
(oracle/python-cx_Oracle#300).
  • Loading branch information
anthony-tuininga committed May 3, 2019
1 parent c059aa8 commit e53746b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dpiUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int dpiUtils__parseNumberString(const char *value, uint32_t valueLength,
return dpiError__set(error, "no digits in exponent",
DPI_ERR_INVALID_NUMBER);
exponentDigits[numExponentDigits] = '\0';
exponent = (int16_t) strtol(exponentDigits, NULL, 0);
exponent = (int16_t) strtol(exponentDigits, NULL, 10);
if (exponentIsNegative)
exponent = -exponent;
*decimalPointIndex += exponent;
Expand Down
4 changes: 2 additions & 2 deletions test/TestNumbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ int dpiTest_205_bindNumberAsString(dpiTestCase *testCase,
const char *outValues[] = { "400000000", "1521000000000000",
"5478000000000000000", "100000000000",
"-1234567890123456789012345678901234567.8", "0", "0", "0", "0",
NULL };
"0.00000001", "0.000000001", NULL };
const char *inValues[] = { "4E+8", "1.521E+15", "5.478E+18", "1E+11",
"-1234567890123456789012345678901234567.8", "0", "-0", "0.0",
"-0.0", NULL };
"-0.0", "1e-08", "1e-09", NULL };
const char *sql = "select :1 from dual";
dpiData *inputVarData, *resultVarData;
dpiVar *inputVar, *resultVar;
Expand Down

0 comments on commit e53746b

Please sign in to comment.