The Augeas documentation states that NULL can be a valid value
associated to a note. Hence, make sure to not crash, and return None
in case there is a single node with NULL value.
Easily reproducible with:
let v = Augeas.get aug "/files" in
int r;
r = aug_get (t, path, &val);
- if (r == 1) { /* Return Some val */
+ if (r == 1 && val) { /* Return Some val */
v = caml_copy_string (val);
optv = caml_alloc (1, 0);
Field (optv, 0) = v;
- } else if (r == 0) /* Return None */
+ } else if (r == 0 || !val) /* Return None */
optv = Val_int (0);
else if (r == -1) /* Error or multiple matches */
raise_error (t, "Augeas.get");