From 34bf4b1d3cb63b51720cbb627865b5001e6eebec Mon Sep 17 00:00:00 2001 From: martin-neuhaeusser Date: Mon, 11 Apr 2016 15:06:28 +0200 Subject: [PATCH] Fix installation of custom error handler during context creation in OCaml bindings This patch fixes a bug detected by valgrind, where a custom error handler did not get installed correctly. --- src/api/ml/z3native_stubs.c.pre | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/ml/z3native_stubs.c.pre b/src/api/ml/z3native_stubs.c.pre index 02bafeef6..47655c57e 100644 --- a/src/api/ml/z3native_stubs.c.pre +++ b/src/api/ml/z3native_stubs.c.pre @@ -436,8 +436,10 @@ void MLErrorHandler(Z3_context c, Z3_error_code e) n_* wrapper functions. */ } -void DLL_PUBLIC n_set_internal_error_handler(value a0) +CAMLprim value DLL_PUBLIC n_set_internal_error_handler(value ctx_v) { - Z3_context _a0 = * (Z3_context*) Data_custom_val(a0); - Z3_set_error_handler(_a0, MLErrorHandler); + CAMLparam1(ctx_v); + Z3_context_plus ctx_p = *(Z3_context_plus*) Data_custom_val(ctx_v); + Z3_set_error_handler(ctx_p->ctx, MLErrorHandler); + CAMLreturn(Val_unit); }