Revision: 53654
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53654&view=rev
Author:   brlcad
Date:     2012-11-11 06:04:42 +0000 (Sun, 11 Nov 2012)
Log Message:
-----------
stop two memory leaks reported by valgrind.  free what we initialized.

Modified Paths:
--------------
    brlcad/trunk/src/librt/db_tree.c
    brlcad/trunk/src/librt/tree.c

Modified: brlcad/trunk/src/librt/db_tree.c
===================================================================
--- brlcad/trunk/src/librt/db_tree.c    2012-11-11 06:03:13 UTC (rev 53653)
+++ brlcad/trunk/src/librt/db_tree.c    2012-11-11 06:04:42 UTC (rev 53654)
@@ -972,12 +972,21 @@
 
     RT_CK_DBTS(tsp);
 
-    if (*orig_str == '\0') return 0;           /* Null string */
+    if (*orig_str == '\0') {
+       return 0; /* Null string */
+    }
 
-    if (db_string_to_path(&new_path, tsp->ts_dbip, orig_str) < 0)
+    db_full_path_init(&new_path);
+
+    if (db_string_to_path(&new_path, tsp->ts_dbip, orig_str) < 0) {
+       db_free_full_path(&new_path);
        return -1;
+    }
 
-    if (new_path.fp_len <= 0) return 0;                /* Null string */
+    if (new_path.fp_len <= 0) {
+       db_free_full_path(&new_path);
+       return 0; /* Null string */
+    }
 
     ret = db_follow_path(tsp, total_path, &new_path, noisy, 0);
     db_free_full_path(&new_path);

Modified: brlcad/trunk/src/librt/tree.c
===================================================================
--- brlcad/trunk/src/librt/tree.c       2012-11-11 06:03:13 UTC (rev 53653)
+++ brlcad/trunk/src/librt/tree.c       2012-11-11 06:04:42 UTC (rev 53654)
@@ -181,12 +181,14 @@
        return TREE_NULL;
 
     bu_avs_init_empty(&avs);
-    if (!db5_get_attributes(tsp->ts_dbip, &avs, dp)) {
+    if (db5_get_attributes(tsp->ts_dbip, &avs, dp) == 0) {
+       /* copy avs */
        bu_avs_init_empty(&(rp->attr_values));
-       for(BU_AVS_FOR(avpp, &(tsp->ts_attrs))) {
+       for (BU_AVS_FOR(avpp, &(tsp->ts_attrs))) {
            bu_avs_add(&(rp->attr_values), avpp->name, bu_avs_get(&avs, 
avpp->name));
        }
     }
+    bu_avs_free(&avs);
 
     rp->reg_mater = tsp->ts_mater; /* struct copy */
     if (tsp->ts_mater.ma_shader)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to