]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
fix crash when cleaning up functions related to [[accumulate]]
authorDale Weiler <weilercdale@gmail.com>
Tue, 27 Oct 2020 23:40:30 +0000 (19:40 -0400)
committerDale Weiler <weilercdale@gmail.com>
Tue, 27 Oct 2020 23:40:30 +0000 (19:40 -0400)
Makefile
parser.cpp

index dc49416daa8e60464c2a1812d2fcf42ffb6c15d1..06690a7298ac839cc80f0fef03abe3625dc9286d 100644 (file)
--- 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
index 9345760ad2d83b3e4825dbe7fb3d729e40f0cbcc..b0afc79c1d990460af4ee2951d522595d42c70fe 100644 (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: