[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/lens.c (lns_make_union, lns_make_concat): do not access free'd memory



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=47b17fff6ddb16f0193d7834d62270a0eced477e
Commit:        47b17fff6ddb16f0193d7834d62270a0eced477e
Parent:        badc0429e02cbb406ff44f6322e3db813ccf2e5f
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Tue Dec 22 11:35:16 2009 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Wed Dec 23 12:18:25 2009 -0800

* src/lens.c (lns_make_union, lns_make_concat): do not access free'd memory

make_lens_binop may free one of the lenses it gets passed. We can therefore
not reference them after a call to make_lens_binop.
---
 src/lens.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lens.c b/src/lens.c
index e837214..68f5468 100644
--- a/src/lens.c
+++ b/src/lens.c
@@ -191,6 +191,7 @@ static struct value *make_lens_value(struct lens *lens) {
 struct value *lns_make_union(struct info *info,
                              struct lens *l1, struct lens *l2, int check) {
     struct lens *lens = NULL;
+    int consumes_value = l1->consumes_value && l2->consumes_value;
 
     if (check) {
         struct value *exn = typecheck_union(info, l1, l2);
@@ -199,13 +200,14 @@ struct value *lns_make_union(struct info *info,
     }
 
     lens = make_lens_binop(L_UNION, info, l1, l2, regexp_union_n);
-    lens->consumes_value = l1->consumes_value && l2->consumes_value;
+    lens->consumes_value = consumes_value;
     return make_lens_value(lens);
 }
 
 struct value *lns_make_concat(struct info *info,
                               struct lens *l1, struct lens *l2, int check) {
     struct lens *lens = NULL;
+    int consumes_value = l1->consumes_value || l2->consumes_value;
 
     if (check) {
         struct value *exn = typecheck_concat(info, l1, l2);
@@ -221,7 +223,7 @@ struct value *lns_make_concat(struct info *info,
     }
 
     lens = make_lens_binop(L_CONCAT, info, l1, l2, regexp_concat_n);
-    lens->consumes_value = l1->consumes_value || l2->consumes_value;
+    lens->consumes_value = consumes_value;
     return make_lens_value(lens);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]