From c9324853e5ecd89228095db2ff4a5723eccc3421 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 26 Feb 2024 09:15:13 -0800 Subject: [PATCH] luau-compile: Fix usage of vector-ctor without vector-lib (#1172) When --vector-lib is not specified, CompileOptions::vectorLib was set to an empty string. This resulted in the builtin matching not working, since vectorLib must either be a null pointer or a pointer to a valid global identifier. --------- Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> --- CLI/Compile.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CLI/Compile.cpp b/CLI/Compile.cpp index c993d3088..ee253d395 100644 --- a/CLI/Compile.cpp +++ b/CLI/Compile.cpp @@ -46,10 +46,9 @@ struct GlobalOptions int optimizationLevel = 1; int debugLevel = 1; - std::string vectorLib; - std::string vectorCtor; - std::string vectorType; - + const char* vectorLib = nullptr; + const char* vectorCtor = nullptr; + const char* vectorType = nullptr; } globalOptions; static Luau::CompileOptions copts() @@ -58,10 +57,9 @@ static Luau::CompileOptions copts() result.optimizationLevel = globalOptions.optimizationLevel; result.debugLevel = globalOptions.debugLevel; - // globalOptions outlive the CompileOptions, so it's safe to use string data pointers here - result.vectorLib = globalOptions.vectorLib.c_str(); - result.vectorCtor = globalOptions.vectorCtor.c_str(); - result.vectorType = globalOptions.vectorType.c_str(); + result.vectorLib = globalOptions.vectorLib; + result.vectorCtor = globalOptions.vectorCtor; + result.vectorType = globalOptions.vectorType; return result; }