X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=parser.c;h=d835a98cc326e279aad509b570b1928d10e8a569;hp=6216997879e461e4c759cb17ec2959b9e362f5aa;hb=17318af62fa6ed5c5b48652150740c9ea241a536;hpb=fe296de42f96780b4a3c7c2647775ec3d8a5e59d diff --git a/parser.c b/parser.c index 6216997..d835a98 100644 --- a/parser.c +++ b/parser.c @@ -949,7 +949,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) if (exprs[1]->vtype != TYPE_FLOAT) { ast_type_to_string(exprs[0], ty1, sizeof(ty1)); ast_type_to_string(exprs[1], ty2, sizeof(ty2)); - compile_error(ctx, "invalid types used in expression: cannot divide tyeps %s and %s", ty1, ty2); + compile_error(ctx, "invalid types used in expression: cannot divide types %s and %s", ty1, ty2); return false; } if (exprs[0]->vtype == TYPE_FLOAT) { @@ -980,7 +980,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) { ast_type_to_string(exprs[0], ty1, sizeof(ty1)); ast_type_to_string(exprs[1], ty2, sizeof(ty2)); - compile_error(ctx, "invalid types used in expression: cannot divide tyeps %s and %s", ty1, ty2); + compile_error(ctx, "invalid types used in expression: cannot divide types %s and %s", ty1, ty2); return false; } break; @@ -2056,7 +2056,7 @@ static bool parse_sya_operand(parser_t *parser, shunt *sy, bool with_labels) correct = correct_str(&corr, parser->correct_variables[i], parser_tokval(parser)); if (strcmp(correct, parser_tokval(parser))) { break; - } else if (correct) { + } else { mem_d(correct); correct = NULL; } @@ -2514,7 +2514,8 @@ static ast_expression* process_condition(parser_t *parser, ast_expression *cond, } unary = (ast_unary*)cond; - while (ast_istype(cond, ast_unary) && unary->op == INSTR_NOT_F) + /* ast_istype dereferences cond, should test here for safety */ + while (cond && ast_istype(cond, ast_unary) && unary->op == INSTR_NOT_F) { cond = unary->operand; unary->operand = NULL; @@ -2754,7 +2755,12 @@ static bool parse_dowhile(parser_t *parser, ast_block *block, ast_expression **o if (vec_last(parser->breaks) != label || vec_last(parser->continues) != label) { parseerror(parser, "internal error: label stack corrupted"); rv = false; - ast_delete(*out); + /* + * Test for NULL otherwise ast_delete dereferences null pointer + * and boom. + */ + if (*out) + ast_delete(*out); *out = NULL; } else {