diff --git a/tools/ocaml/xenstored/syslog_stubs.c b/tools/ocaml/xenstored/syslog_stubs.c index 875d48ad57..e16c3a9491 100644 --- a/tools/ocaml/xenstored/syslog_stubs.c +++ b/tools/ocaml/xenstored/syslog_stubs.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -35,14 +36,16 @@ static int __syslog_facility_table[] = { value stub_syslog(value facility, value level, value msg) { CAMLparam3(facility, level, msg); - const char *c_msg = strdup(String_val(msg)); + char *c_msg = strdup(String_val(msg)); int c_facility = __syslog_facility_table[Int_val(facility)] | __syslog_level_table[Int_val(level)]; + if ( !c_msg ) + caml_raise_out_of_memory(); caml_enter_blocking_section(); syslog(c_facility, "%s", c_msg); caml_leave_blocking_section(); - free((void*)c_msg); + free(c_msg); CAMLreturn(Val_unit); }