[GRASS-SVN] r46445 - grass/branches/develbranch_6/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 29 05:03:33 EDT 2011


Author: mmetz
Date: 2011-05-29 02:03:33 -0700 (Sun, 29 May 2011)
New Revision: 46445

Modified:
   grass/branches/develbranch_6/lib/vector/Vlib/break_lines.c
Log:
fix memory leak

Modified: grass/branches/develbranch_6/lib/vector/Vlib/break_lines.c
===================================================================
--- grass/branches/develbranch_6/lib/vector/Vlib/break_lines.c	2011-05-29 09:00:15 UTC (rev 46444)
+++ grass/branches/develbranch_6/lib/vector/Vlib/break_lines.c	2011-05-29 09:03:33 UTC (rev 46445)
@@ -215,6 +215,8 @@
 
 	    btype = Vect_read_line(Map, BPoints, BCats, bline);
 
+	    AXLines = NULL;
+	    BXLines = NULL;
 	    Vect_line_intersection(APoints, BPoints, &AXLines, &BXLines,
 				   &naxlines, &nbxlines, 0);
 	    G_debug(3, "  naxlines = %d nbxlines = %d", naxlines, nbxlines);
@@ -291,9 +293,10 @@
 		    }
 		    Vect_destroy_line_struct(AXLines[k]);
 		}
-		G_free(AXLines);
 		nbreaks += naxlines - 1;
 	    }
+	    if (AXLines)
+		G_free(AXLines);
 
 	    if (nbxlines > 0) {
 		if (aline != bline) {	/* Self intersection, do not write twice, TODO: is it OK? */
@@ -340,8 +343,9 @@
 		    for (k = 0; k < nbxlines; k++)
 			Vect_destroy_line_struct(BXLines[k]);
 		}
+	    }
+	    if (BXLines)
 		G_free(BXLines);
-	    }
 	    if (Err) {
 		for (l = 0; l < nx; l++) {	/* Write out errors */
 		    Vect_reset_line(Points);



More information about the grass-commit mailing list