Fix memory leaks in CFC

Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f31311e7
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f31311e7
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f31311e7

Branch: refs/heads/master
Commit: f31311e7b52574fb8c377d21bbd65500b04d305f
Parents: 32713e5
Author: Nick Wellnhofer <[email protected]>
Authored: Sun Feb 3 20:59:21 2013 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Sun Feb 3 22:06:00 2013 +0100

----------------------------------------------------------------------
 clownfish/compiler/src/CFCClass.c    |    1 +
 clownfish/compiler/src/CFCDumpable.c |   12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/f31311e7/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c 
b/clownfish/compiler/src/CFCClass.c
index 09ffa68..d3287dd 100644
--- a/clownfish/compiler/src/CFCClass.c
+++ b/clownfish/compiler/src/CFCClass.c
@@ -219,6 +219,7 @@ CFCClass_destroy(CFCClass *self) {
         FREEMEM(attribute->value);
         FREEMEM(attribute);
     }
+    CFCBase_decref((CFCBase*)self->file_spec);
     FREEMEM(self->children);
     FREEMEM(self->functions);
     FREEMEM(self->methods);

http://git-wip-us.apache.org/repos/asf/lucy/blob/f31311e7/clownfish/compiler/src/CFCDumpable.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCDumpable.c 
b/clownfish/compiler/src/CFCDumpable.c
index 14d6204..1853203 100644
--- a/clownfish/compiler/src/CFCDumpable.c
+++ b/clownfish/compiler/src/CFCDumpable.c
@@ -165,10 +165,10 @@ S_add_dump_method(CFCClass *klass) {
     const size_t BUF_SIZE = 400;
     char buf[BUF_SIZE];
 
-    char *full_typedef = CFCMethod_full_typedef(method, klass);
-    char *full_meth    = CFCMethod_full_method_sym(method, klass);
-
     if (parent && CFCClass_has_attribute(parent, "dumpable")) {
+        char *full_typedef = CFCMethod_full_typedef(method, klass);
+        char *full_meth    = CFCMethod_full_method_sym(method, klass);
+
         const char pattern[] =
             "cfish_Obj*\n"
             "%s(%s *self)\n"
@@ -221,10 +221,10 @@ S_add_load_method(CFCClass *klass) {
     const size_t BUF_SIZE = 400;
     char buf[BUF_SIZE];
 
-    char *full_typedef = CFCMethod_full_typedef(method, klass);
-    char *full_meth    = CFCMethod_full_method_sym(method, klass);
-
     if (parent && CFCClass_has_attribute(parent, "dumpable")) {
+        char *full_typedef = CFCMethod_full_typedef(method, klass);
+        char *full_meth    = CFCMethod_full_method_sym(method, klass);
+
         const char pattern[] =
             "cfish_Obj*\n"
             "%s(%s *self, cfish_Obj *dump)\n"

Reply via email to