Imported Upstream version 1.8.0
[platform/upstream/augeas.git] / src / builtin.c
index e674181..8f7078d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * builtin.c: builtin primitives
  *
- * Copyright (C) 2007-2011 David Lutterkort
+ * Copyright (C) 2007-2016 David Lutterkort
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -149,14 +149,13 @@ static void exn_print_tree(struct value *exn, struct tree *tree) {
 static struct value *make_pathx_exn(struct info *info, struct pathx *p) {
     struct value *v;
     char *msg;
-    const char *txt;
+    const char *txt, *px_err;
     int pos;
 
-    msg = strdup(pathx_error(p, &txt, &pos));
-    if (msg == NULL)
-        return NULL;
+    px_err = pathx_error(p, &txt, &pos);
+    v = make_exn_value(ref(info), "syntax error in path expression: %s",
+                       px_err);
 
-    v = make_exn_value(ref(info), "syntax error in path expression: %s", msg);
     if (ALLOC_N(msg, strlen(txt) + 4) >= 0) {
         strncpy(msg, txt, pos);
         strcat(msg, "|=|");
@@ -173,7 +172,7 @@ static struct value *pathx_parse_glue(struct info *info, struct value *tree,
 
     if (pathx_parse(tree->origin, info->error, path->string->str, true,
                     NULL, NULL, p) != PATHX_NOERROR) {
-        return make_pathx_exn(ref(info), *p);
+        return make_pathx_exn(info, *p);
     } else {
         return NULL;
     }