diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2000-08-08 12:26:50 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2000-08-08 12:26:50 +0000 |
commit | c36622eccda51c703e9318e1096c78c9fbbd552c (patch) | |
tree | d7859b6d4d08a881d2ff92c32312ec70d9134262 /byterun/ints.c | |
parent | 668286f4e9ffc0f15266a999d39531fd0b87ee61 (diff) |
int*_of_string: echouer si la chaine contient des chiffres illegaux dans la base courante (PR#178)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3267 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/ints.c')
-rw-r--r-- | byterun/ints.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/byterun/ints.c b/byterun/ints.c index 687662081..c86d13398 100644 --- a/byterun/ints.c +++ b/byterun/ints.c @@ -68,7 +68,7 @@ static long parse_long(char * p) if (d < 0) failwith("int_of_string"); for (p++, res = d; /*nothing*/; p++) { d = parse_digit(p); - if (d < 0) break; + if (d < 0 || d >= base) break; res = base * res + d; } if (*p != 0) failwith("int_of_string"); @@ -406,7 +406,7 @@ value int64_of_string(value s) /* ML */ 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 < 0 || d >= base) break; res = base * res + d; } if (*p != 0) failwith("int_of_string"); |