[augeas-devel] augeas: master - * src/get.c (get_quant_star): do not leak registers

David Lutterkort lutter at fedoraproject.org
Sat Mar 28 00:42:49 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=e4cec147170ec3499d88b3ef6328f24a82caf5cd
Commit:        e4cec147170ec3499d88b3ef6328f24a82caf5cd
Parent:        6427347c731fe04091cd7ca24da9b836ee099d3d
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Fri Mar 27 17:00:42 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Mar 27 17:00:42 2009 -0700

* src/get.c (get_quant_star): do not leak registers

---
 src/get.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/get.c b/src/get.c
index d59d43e..7ab8bad 100644
--- a/src/get.c
+++ b/src/get.c
@@ -267,6 +267,7 @@ static int match(struct state *state, struct lens *lens,
     count = regexp_match(re, state->text, size, start, regs);
     if (count < -1) {
         regexp_match_error(state, lens, count, re);
+        FREE(regs);
         return -1;
     }
     state->regs = regs;
@@ -512,6 +513,7 @@ static struct tree *get_quant_star(struct lens *lens, struct state *state) {
     uint start = REG_START(state);
     uint size = end - start;
 
+    state->regs = NULL;
     while (size > 0 && match(state, child, child->ctype, end, start) > 0) {
         struct tree *t = NULL;
 
@@ -522,6 +524,7 @@ static struct tree *get_quant_star(struct lens *lens, struct state *state) {
         size -= REG_SIZE(state);
         free_regs(state);
     }
+    free_regs(state);
     state->regs = old_regs;
     state->nreg = old_nreg;
     if (size != 0) {
@@ -543,6 +546,7 @@ static struct skel *parse_quant_star(struct lens *lens, struct state *state,
     uint size = end - start;
 
     *dict = NULL;
+    state->regs = NULL;
     while (size > 0 && match(state, child, child->ctype, end, start) > 0) {
         struct skel *sk;
         struct dict *di = NULL;
@@ -555,6 +559,7 @@ static struct skel *parse_quant_star(struct lens *lens, struct state *state,
         size -= REG_SIZE(state);
         free_regs(state);
     }
+    free_regs(state);
     state->regs = old_regs;
     state->nreg = old_nreg;
     if (size != 0) {




More information about the augeas-devel mailing list