fix crash when cleaning up functions related to [[accumulate]]

This commit is contained in:
Dale Weiler 2020-10-27 19:40:30 -04:00
parent f971f89e1e
commit 237722c0b2
2 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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: