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

[augeas-devel] augeas: master - * src/lens.c (free_lens): free recursive lenses



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=5b0fde3b4204a7e3e644c744f40a2a68a40b2cf8
Commit:        5b0fde3b4204a7e3e644c744f40a2a68a40b2cf8
Parent:        69304e5edf7713a06f1c8ad1528839d474761c52
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Fri Dec 18 16:18:46 2009 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Thu Jan 14 14:48:38 2010 -0800

* src/lens.c (free_lens): free recursive lenses

---
 src/lens.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/lens.c b/src/lens.c
index 9f408fc..5cdc31c 100644
--- a/src/lens.c
+++ b/src/lens.c
@@ -709,10 +709,6 @@ void free_lens(struct lens *lens) {
         return;
     assert(lens->ref == 0);
 
-    unref(lens->info, info);
-    for (int t=0; t < ntypes; t++)
-        unref(ltype(lens, t), regexp);
-
     switch (lens->tag) {
     case L_DEL:
         unref(lens->regexp, regexp);
@@ -738,10 +734,23 @@ void free_lens(struct lens *lens) {
             unref(lens->children[i], lens);
         free(lens->children);
         break;
+    case L_REC:
+        if (lens->ref != REF_MAX) {
+            /* Break unbounded recursion */
+            lens->ref = REF_MAX;
+            unref(lens->body, lens);
+        }
+        break;
     default:
         assert(0);
         break;
     }
+
+    for (int t=0; t < ntypes; t++)
+        unref(ltype(lens, t), regexp);
+
+    unref(lens->info, info);
+
     free(lens);
 }
 



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