2626 (v)->type == V_ARRAY)) { \
2727 v_free((v)); \
2828 }
29+ #define V_FREE2 (v ) \
30+ if (((v)->type == V_STR || \
31+ (v)->type == V_MAP || \
32+ (v)->type == V_ARRAY)) { \
33+ v_free((v)); \
34+ }
2935
3036/**
3137 * matrix: convert var_t to double[r][c]
@@ -268,7 +274,7 @@ int v_wc_match(var_t *vwc, var_t *v) {
268274 if (!prog_error ) {
269275 ri = wc_match ((char * ) vwc -> v .p .ptr , (char * ) vt -> v .p .ptr );
270276 }
271- v_free (vt );
277+ V_FREE (vt );
272278 free (vt );
273279 }
274280 return ri ;
@@ -334,7 +340,7 @@ static inline void oper_add(var_t *r, var_t *left) {
334340 break ;
335341 }
336342 v_set (r , & vtmp );
337- v_free (& vtmp );
343+ V_FREE2 (& vtmp );
338344 }
339345 V_FREE (left );
340346 }
@@ -613,7 +619,7 @@ static inline void oper_cmp(var_t *r, var_t *left) {
613619 v = v_clone (left );
614620 v_tostr (v );
615621 ri = (strstr (r -> v .p .ptr , v -> v .p .ptr ) != NULL );
616- v_free (v );
622+ V_FREE (v );
617623 free (v );
618624 }
619625 } else if (r -> type == V_NUM || r -> type == V_INT ) {
@@ -862,7 +868,7 @@ static inline void eval_callf_num(long fcode, var_t *r) {
862868 } else {
863869 IP ++ ;
864870 cmd_ns1 (fcode , & vtmp , r );
865- v_free (& vtmp );
871+ V_FREE2 (& vtmp );
866872 }
867873 }
868874 }
@@ -910,8 +916,8 @@ static inline void eval_callf_imathI1(long fcode, var_t *r) {
910916}
911917
912918static inline void eval_callf_imathI2 (long fcode , var_t * r ) {
913- var_t vtmp ;
914919 // int FUNC(void)
920+ var_t vtmp ;
915921 vtmp .type = V_INT ;
916922 vtmp .v .i = 0 ;
917923 r -> type = V_INT ;
@@ -933,7 +939,7 @@ static inline void eval_callf_mathN1(long fcode, var_t *r) {
933939 IP ++ ;
934940 r -> type = V_NUM ;
935941 r -> v .n = cmd_math1 (fcode , & vtmp );
936- v_free (& vtmp );
942+ V_FREE2 (& vtmp );
937943 }
938944 }
939945 }
@@ -1160,7 +1166,7 @@ static inline void eval_call_udf(var_t *r) {
11601166 } else {
11611167 v_set (r , udf_rv .x .vdvar .vptr );
11621168 // free ret-var
1163- v_free (udf_rv .x .vdvar .vptr );
1169+ V_FREE (udf_rv .x .vdvar .vptr );
11641170 free (udf_rv .x .vdvar .vptr );
11651171 }
11661172 }
@@ -1174,7 +1180,7 @@ void eval(var_t *r) {
11741180 bcip_t eval_pos = eval_sp ;
11751181 byte level = 0 ;
11761182
1177- do {
1183+ while (! prog_error ) {
11781184 code_t code = CODE (IP );
11791185 IP ++ ;
11801186 switch (code ) {
@@ -1312,14 +1318,7 @@ void eval(var_t *r) {
13121318 }
13131319 }
13141320 };
1315-
1316- // run-time error check
1317- if (prog_error ) {
1318- break ;
1319- }
1320-
1321- } while (1 );
1322-
1321+ }
13231322 // restore stack pointer
13241323 eval_sp = eval_pos ;
13251324}
0 commit comments