Browse code

core expr. eval: fix fixup/optimization bug

In some cases some ref'ed rvals were replaced in-place, messing up
the refcnt.

Andrei Pelinescu-Onciul authored on 04/05/2009 20:23:59
Showing 1 changed files
... ...
@@ -3002,7 +3002,7 @@ static int rve_optimize(struct rval_expr* rve)
3002 3002
 	if (rve->op == RVE_RVAL_OP) /* if rval, nothing to do */
3003 3003
 		return 0;
3004 3004
 	if (rve_is_constant(rve)){
3005
-		if ((rv=rval_expr_eval(0, 0, rve))==0){
3005
+		if ((rv=rval_expr_eval_new(0, 0, rve))==0){
3006 3006
 			ERR("optimization failure, bad expression\n");
3007 3007
 			goto error;
3008 3008
 		}
... ...
@@ -3035,7 +3035,7 @@ static int rve_optimize(struct rval_expr* rve)
3035 3035
 		}
3036 3036
 		/* $v - a => $v + (-a)  (easier to optimize)*/
3037 3037
 		if ((rve->op==RVE_MINUS_OP) && (rve_is_constant(rve->right.rve))){
3038
-			if ((rv=rval_expr_eval(0, 0, rve->right.rve))==0){
3038
+			if ((rv=rval_expr_eval_new(0, 0, rve->right.rve))==0){
3039 3039
 				ERR("optimization failure, bad expression\n");
3040 3040
 				goto error;
3041 3041
 			}
... ...
@@ -3114,7 +3114,7 @@ static int rve_optimize(struct rval_expr* rve)
3114 3114
 								" +(+($v, a), b) when typeof(a)==INT\n");
3115 3115
 						return 0;
3116 3116
 					}
3117
-					if ((rv=rval_expr_eval(0, 0, &tmp_rve))==0){
3117
+					if ((rv=rval_expr_eval_new(0, 0, &tmp_rve))==0){
3118 3118
 						ERR("optimization failure, bad expression\n");
3119 3119
 						goto error;
3120 3120
 					}
... ...
@@ -3146,7 +3146,7 @@ static int rve_optimize(struct rval_expr* rve)
3146 3146
 					   cases are caught by rve_op_is_commutative()
3147 3147
 					   (in this case type will be typeof(a)) => ok only if
3148 3148
 					   typeof(a) is int) */
3149
-					if ((rv=rval_expr_eval(0, 0, &tmp_rve))==0){
3149
+					if ((rv=rval_expr_eval_new(0, 0, &tmp_rve))==0){
3150 3150
 						ERR("optimization failure, bad expression\n");
3151 3151
 						goto error;
3152 3152
 					}
... ...
@@ -3188,7 +3188,7 @@ static int rve_optimize(struct rval_expr* rve)
3188 3188
 					   cases are caught by rve_op_is_commutative()
3189 3189
 					   (in this case type will be typeof(a)) => ok only if
3190 3190
 					   typeof(a) is int) */
3191
-					if ((rv=rval_expr_eval(0, 0, &tmp_rve))==0){
3191
+					if ((rv=rval_expr_eval_new(0, 0, &tmp_rve))==0){
3192 3192
 						ERR("optimization failure, bad expression\n");
3193 3193
 						goto error;
3194 3194
 					}
... ...
@@ -3224,7 +3224,7 @@ static int rve_optimize(struct rval_expr* rve)
3224 3224
 								" +(a, +(b, $v)) when typeof(a)!=typeof(b)\n");
3225 3225
 						return 0;
3226 3226
 					}
3227
-					if ((rv=rval_expr_eval(0, 0, &tmp_rve))==0){
3227
+					if ((rv=rval_expr_eval_new(0, 0, &tmp_rve))==0){
3228 3228
 						ERR("optimization failure, bad expression\n");
3229 3229
 						goto error;
3230 3230
 					}