Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int64.of_string #2548

Closed
vicuna opened this issue Aug 7, 2000 · 2 comments
Closed

Int64.of_string #2548

vicuna opened this issue Aug 7, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 7, 2000

Original bug ID: 178
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi!

the ints.c module does not check the size of digits with respect to the
chosen base:

Int64.of_string "abcd";;

  • : int64 = <int64 11233>

I'd like to suggest the following patch in int64_of_string:

p = parse_sign_and_base(String_val(s), &base, &sign);
for (res = 0; /nothing/; p++) {
d = parse_digit(p);
if (d < 0) break;
if (d >= base) break; /** new - check digit with respect to base **/
res = base * res + d;
}
if (*p != 0) failwith("int_of_string");

-- Christian

--
Christian Lindig Harvard University - EECS
lindig@eecs.harvard.edu 33 Oxford St, MD 242, Cambridge MA 02138
phone: (617) 496-7157 http://www.eecs.harvard.edu/~lindig/

@vicuna
Copy link
Author

vicuna commented Aug 8, 2000

Comment author: administrator

the ints.c module does not check the size of digits with respect to the
chosen base:

Int64.of_string "abcd";;

  • : int64 = <int64 11233>

You are right. This bug is also present in int_of_string and Int32.of_string.
This is now fixed in the working sources. Thanks,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Aug 8, 2000

Comment author: administrator

Fixed 2000-08-08 by Xavier

@vicuna vicuna closed this as completed Aug 8, 2000
This was referenced Mar 14, 2019
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant