[augeas-devel] [PATCH 07 of 11] Do not leak the split on error
David Lutterkort
dlutter at redhat.com
Thu May 15 20:01:57 UTC 2008
1 file changed, 5 insertions(+), 6 deletions(-)
src/put.c | 11 +++++------
# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1210881509 25200
# Node ID 5281beb9ad8aa18b520779cc1e0f56b156751957
# Parent 69d8a9d1caf128573a314c9e268894f2e89809ef
Do not leak the split on error
put_subtree has to free the split it computes; previously, it leaked that
if an error inside the subtree occurred.
diff -r 69d8a9d1caf1 -r 5281beb9ad8a src/put.c
--- a/src/put.c Thu May 15 12:58:17 2008 -0700
+++ b/src/put.c Thu May 15 12:58:29 2008 -0700
@@ -387,11 +387,13 @@ static void put_subtree(struct lens *len
struct tree *tree = state->split->tree;
struct dict_entry *entry = dict_lookup(tree->label, state->dict);
+ struct split *split = NULL;
+
state->key = tree->label;
state->value = tree->value;
pathjoin(&state->path, 1, state->key);
- state->split = make_split(tree->children);
+ state->split = split = make_split(tree->children);
if (entry == NULL) {
state->skel = NULL;
@@ -402,16 +404,13 @@ static void put_subtree(struct lens *len
state->dict = entry->dict;
put_lens(lens->child, state);
}
-
- if (state->error == NULL) {
- assert(state->split->next == NULL);
- free_split(state->split);
- }
+ assert(state->error != NULL || state->split->next == NULL);
oldstate.error = state->error;
oldstate.path = state->path;
*state = oldstate;
*state->split= oldsplit;
+ free_split(split);
state->path[oldpathlen] = '\0';
}
More information about the augeas-devel
mailing list