[GRASS-SVN] r46444 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 29 05:00:15 EDT 2011


Author: mmetz
Date: 2011-05-29 02:00:15 -0700 (Sun, 29 May 2011)
New Revision: 46444

Modified:
   grass/trunk/lib/vector/Vlib/break_lines.c
   grass/trunk/lib/vector/Vlib/build_nat.c
Log:
fix memory leak

Modified: grass/trunk/lib/vector/Vlib/break_lines.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_lines.c	2011-05-29 08:59:57 UTC (rev 46443)
+++ grass/trunk/lib/vector/Vlib/break_lines.c	2011-05-29 09:00:15 UTC (rev 46444)
@@ -216,6 +216,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);
@@ -292,9 +294,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? */
@@ -341,8 +344,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);

Modified: grass/trunk/lib/vector/Vlib/build_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build_nat.c	2011-05-29 08:59:57 UTC (rev 46443)
+++ grass/trunk/lib/vector/Vlib/build_nat.c	2011-05-29 09:00:15 UTC (rev 46444)
@@ -564,7 +564,7 @@
 		if (format == G_INFO_FORMAT_PLAIN)
 		    fprintf(stderr, "%d..", i);
 		else
-		    fprintf(stderr, "%11d\b\b\b\b\b\b\b\b\b\b\b", i);
+		    fprintf(stderr, "%10d\b\b\b\b\b\b\b\b\b\b", i);
 	    }
 
 	    i++;



More information about the grass-commit mailing list