From 47a2548cbfbb977e9b1f0c749bd83d47b4c4596b Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 13 Dec 2022 20:39:49 -0800 Subject: Fix crash in `startSamplingProfiler` --- src/bun.js/bindings/BunJSCModule.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/bun.js/bindings/BunJSCModule.cpp') diff --git a/src/bun.js/bindings/BunJSCModule.cpp b/src/bun.js/bindings/BunJSCModule.cpp index a89bba52a..fd92b817e 100644 --- a/src/bun.js/bindings/BunJSCModule.cpp +++ b/src/bun.js/bindings/BunJSCModule.cpp @@ -265,18 +265,16 @@ JSC_DEFINE_HOST_FUNCTION(functionStartSamplingProfiler, (JSC::JSGlobalObject * g auto scope = DECLARE_THROW_SCOPE(vm); if (directoryValue.isString()) { - WTF::String optionString = WTF::String::fromUTF8("samplingProfilerPath="); auto path = directoryValue.toWTFString(globalObject); if (!path.isEmpty()) { StringPrintStream pathOut; - const char* optionCString = toCString(String(optionString + path)).data(); - - if (!Bun__mkdirp(globalObject, optionCString)) { + auto pathCString = toCString(String(path)); + if (!Bun__mkdirp(globalObject, pathCString.data())) { throwVMError(globalObject, scope, createTypeError(globalObject, "directory couldn't be created"_s)); return JSC::JSValue::encode(jsUndefined()); } - Options::setOption(optionCString); + Options::samplingProfilerPath() = pathCString.data(); samplingProfiler.registerForReportAtExit(); } } -- cgit v1.2.3