From ac7e5def3252291a3a8e95651edc63bf62c523a6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 Apr 2018 15:18:30 +0300 Subject: [PATCH] Forbade dynamic array as the return type of a function Compiler ignored this case silently but it crashed during code generation --- src/scripting/zscript/zcc_compile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 4d530c8a5..1068501d6 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2316,6 +2316,11 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool // structs and classes only get passed by pointer. type = NewPointer(type); } + else if (type->isDynArray()) + { + Error(f, "The return type of a function cannot be a dynamic array"); + break; + } // TBD: disallow certain types? For now, let everything pass that isn't an array. rets.Push(type); t = static_cast(t->SiblingNext);