From: Dale Weiler Date: Tue, 27 Oct 2020 23:40:30 +0000 (-0400) Subject: fix crash when cleaning up functions related to [[accumulate]] X-Git-Tag: xonotic-v0.8.5~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=237722c0b2065f3abf32f479fffaf59105dff150;p=xonotic%2Fgmqcc.git fix crash when cleaning up functions related to [[accumulate]] --- diff --git a/Makefile b/Makefile index dc49416..06690a7 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ ifeq ($(UBSAN),1) endif # Strip the binaries when not a debug build -ifneq (,$(findstring, -g,$(CXXFLAGS))) +ifneq (,$(findstring -g,$(CXXFLAGS))) STRIP := true else STRIP := strip diff --git a/parser.cpp b/parser.cpp index 9345760..b0afc79 100644 --- a/parser.cpp +++ b/parser.cpp @@ -4178,8 +4178,18 @@ static bool parse_function_body(parser_t *parser, ast_value *var) enderrfn: (void)!parser_leaveblock(parser); - parser->functions.pop_back(); + delete func; + + // Remove |func| from |parser->functions|. It may not actually be at the + // back of the vector for accumulated functions. + for (auto it = parser->functions.begin(); it != parser->functions.end(); it++) { + if (*it == func) { + parser->functions.erase(it, it + 1); + break; + } + } + var->m_constval.vfunc = nullptr; enderr: