From: Dale Weiler Date: Sat, 1 Jun 2013 20:18:53 +0000 (+0000) Subject: Fix some possible memleaks. X-Git-Tag: v0.3.0~151^2~28 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=062180e9a8578ffbbf941154f2c4fd43163d2ca4;p=xonotic%2Fgmqcc.git Fix some possible memleaks. --- diff --git a/parser.c b/parser.c index 97a3ccb..14d58b6 100644 --- a/parser.c +++ b/parser.c @@ -5060,6 +5060,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va /* parse on */ if (!parser_next(parser)) { ast_delete(var); + mem_d(name); parseerror(parser, "error after variable or field declaration"); return NULL; } @@ -5069,8 +5070,10 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va if (parser->tok == '[') { wasarray = true; var = parse_arraysize(parser, var); - if (!var) + if (!var) { + if (name) mem_d(name); return NULL; + } } /* This is the point where we can turn it into a field */ @@ -5089,8 +5092,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va while (parser->tok == '(') { var = parse_parameter_list(parser, var); if (!var) { - if (name) - mem_d((void*)name); + if (name) mem_d(name); return NULL; } } @@ -5099,11 +5101,12 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va if (name) { if (!ast_value_set_name(var, name)) { ast_delete(var); + mem_d(name); parseerror(parser, "internal error: failed to set name"); return NULL; } /* free the name, ast_value_set_name duplicates */ - mem_d((void*)name); + mem_d(name); } return var; diff --git a/util.c b/util.c index d695ae6..54f8d56 100644 --- a/util.c +++ b/util.c @@ -170,7 +170,6 @@ static void util_dumpmem(struct memblock_t *memory, uint16_t cols) { void util_meminfo() { struct memblock_t *info; - if (OPTS_OPTION_BOOL(OPTION_DEBUG)) { for (info = mem_start; info; info = info->next) { con_out("lost: %u (bytes) at %s:%u\n", @@ -178,7 +177,7 @@ void util_meminfo() { info->file, info->line); - util_dumpmem(info, OPTS_OPTION_U16(OPTION_MEMDUMPCOLS)); + util_dumpmem(info + 1, OPTS_OPTION_U16(OPTION_MEMDUMPCOLS)); } }