Skip to content

Commit

Permalink
Safer Safe_String_val implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Jul 21, 2020
1 parent c925d64 commit 182e88d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ocaml_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static struct custom_operations binaryen_ops;
#define Is_none(v) ((v) == Val_none)
#define Is_some(v) Is_block(v)

#define Safe_String_val(v) strdup(String_val(v))
#define Safe_String_val(v) memcpy(malloc(caml_string_length(v) + 1), String_val(v), caml_string_length(v) + 1)

CAMLprim value
caml_alloc_some(value v);
Expand Down

0 comments on commit 182e88d

Please sign in to comment.