Revision: 56755
          http://sourceforge.net/p/brlcad/code/56755
Author:   brlcad
Date:     2013-08-12 19:22:40 +0000 (Mon, 12 Aug 2013)
Log Message:
-----------
more null dereferencing checks so that we don't segfault and using 0x7L 
consistently as a long.  should not be encountering the INTERNAL ERROR debug 
line... but we are.  definitely a pooched tree.

Modified Paths:
--------------
    brlcad/trunk/src/librt/primitives/bot/tie.c

Modified: brlcad/trunk/src/librt/primitives/bot/tie.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/tie.c 2013-08-12 19:19:38 UTC (rev 
56754)
+++ brlcad/trunk/src/librt/primitives/bot/tie.c 2013-08-12 19:22:40 UTC (rev 
56755)
@@ -154,11 +154,11 @@
 
     /* Free Triangle Data */
     for (i = 0; i < tie->tri_num; i++)
-       free ((void *)((intptr_t)(tie->tri_list[i].v) & ~0x7L));
-    bu_free (tie->tri_list, "tie_free");
+       bu_free((void *)((intptr_t)(tie->tri_list[i].v) & ~0x7L), "tie_free");
+    bu_free(tie->tri_list, "tie_free");
 
     /* Free KDTREE Nodes */
-    tie_kdtree_free (tie);
+    tie_kdtree_free(tie);
 }
 
 
@@ -267,7 +267,7 @@
         *
         * Gordon Stoll's Mantra - Rays are Measured in Millions :-)
         */
-       while (TIE_HAS_CHILDREN(node_aligned->data)) {
+       while (node_aligned && node_aligned->data && 
TIE_HAS_CHILDREN(node_aligned->data)) {
            ray->kdtree_depth++;
 
            /* Retrieve the splitting plane */
@@ -293,16 +293,19 @@
            far = dist;
        }
 
+       if (!node_aligned || !node_aligned->data) {
+           /* bu_log("INTERNAL ERROR: Unexpected TIE tree traversal 
encountered\n"); */
+           continue;
+       }
 
        /*
         * RAY/TRIANGLE INTERSECTION - Only gets executed on geometry nodes.
         * This part of the function is being executed because the KDTREE 
Traversal is Complete.
         */
+
+       hit_count = 0;
        data = (struct tie_geom_s *)(node_aligned->data);
-       if (data->tri_num == 0)
-           continue;
 
-       hit_count = 0;
        for (i = 0; i < data->tri_num; i++) {
            /*
             * Triangle Intersection Code
@@ -331,8 +334,8 @@
            /* Extract i1 and i2 indices from lower bits of the v pointer */
            v = (tfloat *)((intptr_t)(tri->v) & ~0x7L);
 
-           i1 = TIE_TAB1[((intptr_t)(tri->v) & 0x7)];
-           i2 = TIE_TAB1[3 + ((intptr_t)(tri->v) & 0x7)];
+           i1 = TIE_TAB1[((intptr_t)(tri->v) & 0x7L)];
+           i2 = TIE_TAB1[3 + ((intptr_t)(tri->v) & 0x7L)];
 
            /* Compute U and V */
            u0 = t.pos[i1] - tri->data[0].v[i1];

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to