Raise Out_of_memory when Augeas fails with AUG_ENOMEM
authorPino Toscano <ptoscano@redhat.com>
Wed, 13 Sep 2017 16:25:00 +0000 (18:25 +0200)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 13 Sep 2017 16:56:43 +0000 (17:56 +0100)
This is more in style with what OCaml reports in this kind of
situations.

augeas-c.c

index 7ca7244..5c330a8 100644 (file)
@@ -35,6 +35,11 @@ typedef augeas *augeas_t;
 static void
 raise_error (augeas_t t, const char *msg)
 {
+  const int code = aug_error (t);
+
+  if (code == AUG_ENOMEM)
+    caml_raise_out_of_memory ();
+
   caml_raise_with_string (*caml_named_value ("Augeas.Error"), msg);
 }