Skip to content

Commit

Permalink
fix PR#7003 and a few other bugs caused by misuse of Int_val
Browse files Browse the repository at this point in the history
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16525 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
Damien Doligez committed Oct 19, 2015
1 parent c9f0dc9 commit 659615c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Changes
Expand Up @@ -204,8 +204,10 @@ Bug fixes:
%s#row when Bar contains private row types
- PR#6992: Segfault from bug in GADT/module typing
- PR#6993: Segfault from recursive modules violating exhaustiveness assumptions
- PR#7003: String.sub causes segmentation fault
(Damien Doligez, report by Radek Micek)
- PR#7008: Fatal error in ocamlc with empty compilation unit name
(Damien Doligez)
(Damien Doligez, report by Cesar Kunz)
- PR#7012: Variable name forgotten when it starts with a capital letter
(Jacques Garrigue, Gabriel Scherer, report by Thomas Leonard and Octachron)
- PR#7016: Stack overflow in GADT typing
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1,4 +1,4 @@
4.03.0+dev10-2015-07-29
4.03.0+dev11-2015-10-19

# The version string is the first line of this file.
# It must be in the format described in stdlib/sys.mli
4 changes: 2 additions & 2 deletions byterun/alloc.c
Expand Up @@ -153,7 +153,7 @@ CAMLexport int caml_convert_flag_list(value list, int *flags)
/* [size] is a [value] representing number of words (fields) */
CAMLprim value caml_alloc_dummy(value size)
{
mlsize_t wosize = Int_val(size);
mlsize_t wosize = Long_val(size);

if (wosize == 0) return Atom(0);
return caml_alloc (wosize, 0);
Expand All @@ -169,7 +169,7 @@ CAMLprim value caml_alloc_dummy_function(value size,value arity)
/* [size] is a [value] representing number of floats. */
CAMLprim value caml_alloc_dummy_float (value size)
{
mlsize_t wosize = Int_val(size) * Double_wosize;
mlsize_t wosize = Long_val(size) * Double_wosize;

if (wosize == 0) return Atom(0);
return caml_alloc (wosize, 0);
Expand Down
2 changes: 1 addition & 1 deletion byterun/intern.c
Expand Up @@ -291,7 +291,7 @@ static void intern_rec(value *dest)
case OFreshOID:
/* Refresh the object ID */
/* but do not do it for predefined exception slots */
if (Int_val(Field((value)dest, 1)) >= 0)
if (Long_val(Field((value)dest, 1)) >= 0)
caml_set_oo_id((value)dest);
/* Pop item and iterate */
sp--;
Expand Down
4 changes: 2 additions & 2 deletions byterun/str.c
Expand Up @@ -266,7 +266,7 @@ CAMLprim value caml_string_greaterequal(value s1, value s2)
CAMLprim value caml_blit_string(value s1, value ofs1, value s2, value ofs2,
value n)
{
memmove(&Byte(s2, Long_val(ofs2)), &Byte(s1, Long_val(ofs1)), Int_val(n));
memmove(&Byte(s2, Long_val(ofs2)), &Byte(s1, Long_val(ofs1)), Long_val(n));
return Val_unit;
}

Expand All @@ -278,7 +278,7 @@ CAMLprim value caml_fill_string(value s, value offset, value len, value init)

CAMLprim value caml_bitvect_test(value bv, value n)
{
int pos = Int_val(n);
intnat pos = Long_val(n);
return Val_int(Byte_u(bv, pos >> 3) & (1 << (pos & 7)));
}

Expand Down

1 comment on commit 659615c

@pascal-cuoq
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have just independently encountered the caml_blit_string part of this issue, and a fix is already available nine days ago. Great job!

Please sign in to comment.