diff lwlib/lw_expr.c @ 438:22bbb716dea6 3.0

Fixed memory leaks related to expressions; bumped version to 3.0.1
author lost@l-w.ca
date Sat, 30 Oct 2010 10:40:26 -0600
parents d7d7e4dca3e7
children 367bdde181be
line wrap: on
line diff
--- a/lwlib/lw_expr.c	Fri Oct 29 19:28:54 2010 -0600
+++ b/lwlib/lw_expr.c	Sat Oct 30 10:40:26 2010 -0600
@@ -97,8 +97,13 @@
 	struct lw_expr_opers *o;
 	if (!E)
 		return;
-	for (o = E -> operands; o; o = o -> next)
+	while (E -> operands)
+	{
+		o = E -> operands;
+		E -> operands = o -> next;
 		lw_expr_destroy(o -> p);
+		lw_Free(o);
+	}
 	if (E -> type == lw_expr_type_var)
 		lw_free(E -> value2);
 	lw_free(E);
@@ -119,7 +124,7 @@
 		r -> value2 = lw_strdup(E -> value2);
 	for (o = E -> operands; o; o = o -> next)
 	{
-		lw_expr_add_operand(r, lw_expr_copy(o -> p));
+		lw_expr_add_operand(r, o -> p);
 	}
 	
 	return r;