diff options
author | Karl Williamson <khw@cpan.org> | 2019-01-18 11:30:00 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-01-18 21:48:16 -0700 |
commit | aac39b038830b7472ba3f079b4aee72cb2076c2e (patch) | |
tree | 9925a0eb6af94e85d0340277adf3df64ddc66309 /numeric.c | |
parent | 0657084328c6c5c8225ddf2ce8238561011f6bff (diff) | |
download | perl-aac39b038830b7472ba3f079b4aee72cb2076c2e.tar.gz |
my_atof3() Fix uncommon bug where it wrongly fails
This bug showed up only on -Dusemymalloc without Debugging, and without
various other common Configure options.
It causes my_atof3() to return failure where in fact success was
achieved. It apparently got triggered due to slight differences in
malloc behaviors.
The bug is that it changed a string pointer to new memory and forgot to
change it back to the original value when that memory got freed. The
test that fails is an equal/not equal of two pointers, and usually two
pointers aren't the same, meaning the bug doesn't appear.
The only case where my_atof3() is called is in parsing certain
\p{nv=...} where "..." is not a rational number. So the scope of this
bug is limited.
Spotted by Ryan Voots.
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1465,6 +1465,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len) /* If we created a copy, 'endp' is in terms of that. Convert back to * the original */ if (copy) { + s = (s - copy) + (char *) orig; endp = (endp - copy) + (char *) orig; Safefree(copy); } |