[augeas-devel] [PATCH 04 of 11] Don't leak SNAME

David Lutterkort dlutter at redhat.com
Thu May 15 20:01:54 UTC 2008


1 file changed, 9 insertions(+), 7 deletions(-)
src/parser.y |   16 +++++++++-------


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1210881474 25200
# Node ID 22c806927294319817811a1e0798a51785d107db
# Parent  d9513f74d9575a85011d51ca95da881a80ca2b04
Don't leak SNAME

diff -r d9513f74d957 -r 22c806927294 src/parser.y
--- a/src/parser.y	Thu May 15 12:57:41 2008 -0700
+++ b/src/parser.y	Thu May 15 12:57:54 2008 -0700
@@ -293,8 +293,9 @@ tree_label: DQUOTED
 
 int augl_parse_file(const char *name, struct term **term) {
   yyscan_t       scanner;
-  struct string  *sname;
+  struct string  *sname = NULL;
   struct info    info;
+  int result = -1;
   int r;
 
   *term = NULL;
@@ -306,7 +307,7 @@ int augl_parse_file(const char *name, st
   info.filename = sname;
   if (augl_init_lexer(sname, &scanner) != 0) {
     augl_error(&info, term, NULL, "file not found");
-    goto error;
+    goto done;
   }
 
   yydebug = getenv("YYDEBUG") != NULL;
@@ -314,16 +315,17 @@ int augl_parse_file(const char *name, st
   augl_lex_destroy(scanner);
   if (r == 1) {
     augl_error(&info, term, NULL, "syntax error");
-    goto error;
+    goto done;
   } else if (r == 2) {
     augl_error(&info, term, NULL, "parser ran out of memory");
-    goto error;
+    goto done;
   }
-  return 0;
+  result = 0;
 
- error:
+ done:
+  unref(sname, string);
   // free TERM
-  return -1;
+  return result;
 }
 
 // FIXME: Nothing here checks for alloc errors.




More information about the augeas-devel mailing list