You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the course of adding support to CSV.jl for being able to load into arbitrary AbstractFloat types, via a keyword argument floattype (which defaults to Float64),
I ran into a number of bugs (both in v0.4.x and v0.5-dev). The problem occurs because pointer_to_string() does not create a string that has a terminating \0 (which I feel is correct),
but Cstring does not ensure that a string passed to C has a terminating \0.
This is inconsistent with Cwstring, which does make sure that a Cwstring does have a terminating Cwchar(0).
I'd make a PR to fix these bugs, but since I'm unable to, I'm posting the issue here.
Here are some test cases demonstrating the bugs:
julia> s ="53.9abcdef""53.9abcdef"
julia> u =pointer_to_string(pointer(s.data),2)
"53"
julia> t =pointer_to_string(pointer(s.data),4)
"53.9"
julia>parse(Dec64, t)
ERROR: ArgumentError: invalid number format 53.9in parse at /j/DecFP.jl/src/DecFP.jl:82
julia>parse(Dec64, u)
ERROR: ArgumentError: invalid number format 53in parse at /j/DecFP.jl/src/DecFP.jl:82
julia>parse(BigInt, u)
ERROR: ArgumentError: invalid BigInt:"53"in tryparse_internal at gmp.jl:104in parse at parse.jl:146
julia>parse(BigFloat, t)
ERROR: ArgumentError: invalid number format "53.9"for BigFloat
in parse at parse.jl:164
The text was updated successfully, but these errors were encountered:
Should fix#16499. Two things I'm not sure about:
1. whether it is okay to use `unsafe_load` in this manner?
2. is this the appropriate place to call `String`, or should it be done in `cconvert`?
Should fix#16499. Two things I'm not sure about:
1. whether it is okay to use `unsafe_load` in this manner?
2. is this the appropriate place to call `String`, or should it be done in `cconvert`?
simonbyrne
changed the title
Bugs parsing BigInt/Float &Decimals when no \0 immediately past endCstring does not check for null-termination
Jun 3, 2016
This is pasted verbatim from @ScottPJones report at julia-dev:
In the course of adding support to CSV.jl for being able to load into arbitrary
AbstractFloat
types, via a keyword argumentfloattype
(which defaults toFloat64
),I ran into a number of bugs (both in v0.4.x and v0.5-dev). The problem occurs because pointer_to_string() does not create a string that has a terminating
\0
(which I feel is correct),but
Cstring
does not ensure that a string passed to C has a terminating\0
.This is inconsistent with
Cwstring
, which does make sure that aCwstring
does have a terminatingCwchar(0)
.I'd make a PR to fix these bugs, but since I'm unable to, I'm posting the issue here.
Here are some test cases demonstrating the bugs:
The text was updated successfully, but these errors were encountered: