(svn r1959) -Fix: Repaired two memleaks I have hacked :(
authorCelestar
Tue, 08 Mar 2005 16:27:26 +0000
changeset 1455 000d198ea8f6
parent 1454 03c4de053282
child 1456 9d1279ded01c
(svn r1959) -Fix: Repaired two memleaks I have hacked :(
roadveh_cmd.c
train_cmd.c
--- a/roadveh_cmd.c	Tue Mar 08 00:26:30 2005 +0000
+++ b/roadveh_cmd.c	Tue Mar 08 16:27:26 2005 +0000
@@ -1697,8 +1697,11 @@
 		//We do not have a slot, so make one
 		if (v->u.road.slot == NULL) {
 			//first we need to find out how far our stations are away.
-			if ( rs == NULL )
+			if ( rs == NULL ) {
+				free(firststop);
+				firststop = stop = NULL;
 				goto no_stop;
+			}
 
 			DEBUG(ms, 2) ("Multistop: Attempting to obtain a slot for vehicle %d at station %d (0x%x)", v->unitnumber, st->index, st->xy);
 			do {
--- a/train_cmd.c	Tue Mar 08 00:26:30 2005 +0000
+++ b/train_cmd.c	Tue Mar 08 16:27:26 2005 +0000
@@ -131,6 +131,9 @@
 		sum += dist[i];
 	}
 
+	free(dist);
+	dist = NULL;
+
 	if (numcurve > 0) {
 		sum /= numcurve;
 	}