diff options
author | Alexander Skvortsov <sasha.skvortsov109@gmail.com> | 2023-04-16 14:10:01 -0400 |
---|---|---|
committer | Alexander Skvortsov <sasha.skvortsov109@gmail.com> | 2023-04-16 14:10:01 -0400 |
commit | c4ab7ede4193fde3262283deb49b0c8d56f63b8b (patch) | |
tree | 26052a8936c84994269b0693c45b7183bae97f0f | |
parent | 3fafc3412d4a953b96aae2ccc0d8be4195b68fe0 (diff) | |
download | ocaml-c4ab7ede4193fde3262283deb49b0c8d56f63b8b.tar.gz |
feat: `caml_fatal_error` on misuse of serialize functions
These should only be called from within a `caml_output_*` entrypoint context.
Signed-off-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
-rw-r--r-- | runtime/extern.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/extern.c b/runtime/extern.c index 7ca8d18a89..fe0e5a1cee 100644 --- a/runtime/extern.c +++ b/runtime/extern.c @@ -145,6 +145,13 @@ static struct caml_extern_state* prepare_extern_state (void) static struct caml_extern_state* get_extern_state (void) { Caml_check_caml_state(); + + if (Caml_state->extern_state == NULL) + caml_fatal_error ( + "extern_state not initialized:" + "this function can only be called from a `caml_output_*` entrypoint." + ); + return Caml_state->extern_state; } |