comparison lwasm/pseudo.c @ 208:fa835b780ffb

Fix crash on conditionals with undefined symbols Fix NULL pointer deref when parsing conditionals using undefined symbols.
author William Astle <lost@l-w.ca>
date Sat, 09 Jun 2012 15:57:58 -0600
parents 1824cabf25ce
children f87c86668d6b
comparison
equal deleted inserted replaced
207:07e1fac76321 208:fa835b780ffb
1012 skip_operand(p); 1012 skip_operand(p);
1013 return; 1013 return;
1014 } 1014 }
1015 1015
1016 e = lwasm_parse_cond(as, p); 1016 e = lwasm_parse_cond(as, p);
1017 lwasm_reduce_expr(as, e); 1017 if (e)
1018 lwasm_reduce_expr(as, e);
1018 if (e && lw_expr_intval(e) != 0) 1019 if (e && lw_expr_intval(e) != 0)
1019 { 1020 {
1020 as -> skipcond = 1; 1021 as -> skipcond = 1;
1021 as -> skipcount = 1; 1022 as -> skipcount = 1;
1022 } 1023 }
1034 skip_operand(p); 1035 skip_operand(p);
1035 return; 1036 return;
1036 } 1037 }
1037 1038
1038 e = lwasm_parse_cond(as, p); 1039 e = lwasm_parse_cond(as, p);
1039 lwasm_reduce_expr(as, e); 1040 if (e)
1041 lwasm_reduce_expr(as, e);
1040 if (e && lw_expr_intval(e) == 0) 1042 if (e && lw_expr_intval(e) == 0)
1041 { 1043 {
1042 as -> skipcond = 1; 1044 as -> skipcond = 1;
1043 as -> skipcount = 1; 1045 as -> skipcount = 1;
1044 } 1046 }
1057 skip_operand(p); 1059 skip_operand(p);
1058 return; 1060 return;
1059 } 1061 }
1060 1062
1061 e = lwasm_parse_cond(as, p); 1063 e = lwasm_parse_cond(as, p);
1062 lwasm_reduce_expr(as, e); 1064 if (e)
1065 lwasm_reduce_expr(as, e);
1063 if (e && lw_expr_intval(e) <= 0) 1066 if (e && lw_expr_intval(e) <= 0)
1064 { 1067 {
1065 as -> skipcond = 1; 1068 as -> skipcond = 1;
1066 as -> skipcount = 1; 1069 as -> skipcount = 1;
1067 } 1070 }
1079 skip_operand(p); 1082 skip_operand(p);
1080 return; 1083 return;
1081 } 1084 }
1082 1085
1083 e = lwasm_parse_cond(as, p); 1086 e = lwasm_parse_cond(as, p);
1084 lwasm_reduce_expr(as, e); 1087 if (e)
1088 lwasm_reduce_expr(as, e);
1085 if (e && lw_expr_intval(e) < 0) 1089 if (e && lw_expr_intval(e) < 0)
1086 { 1090 {
1087 as -> skipcond = 1; 1091 as -> skipcond = 1;
1088 as -> skipcount = 1; 1092 as -> skipcount = 1;
1089 } 1093 }
1101 skip_operand(p); 1105 skip_operand(p);
1102 return; 1106 return;
1103 } 1107 }
1104 1108
1105 e = lwasm_parse_cond(as, p); 1109 e = lwasm_parse_cond(as, p);
1106 lwasm_reduce_expr(as, e); 1110 if (e)
1111 lwasm_reduce_expr(as, e);
1107 if (e && lw_expr_intval(e) >= 0) 1112 if (e && lw_expr_intval(e) >= 0)
1108 { 1113 {
1109 as -> skipcond = 1; 1114 as -> skipcond = 1;
1110 as -> skipcount = 1; 1115 as -> skipcount = 1;
1111 } 1116 }
1123 skip_operand(p); 1128 skip_operand(p);
1124 return; 1129 return;
1125 } 1130 }
1126 1131
1127 e = lwasm_parse_cond(as, p); 1132 e = lwasm_parse_cond(as, p);
1128 lwasm_reduce_expr(as, e); 1133 if (e)
1134 lwasm_reduce_expr(as, e);
1129 if (e && lw_expr_intval(e) > 0) 1135 if (e && lw_expr_intval(e) > 0)
1130 { 1136 {
1131 as -> skipcond = 1; 1137 as -> skipcond = 1;
1132 as -> skipcount = 1; 1138 as -> skipcount = 1;
1133 } 1139 }