Skip to content

Commit ad3dfb3

Browse files
committed
transform-sdk/js: fix asan violation
New versions of quickjs unconditionally touch ctx, so we need to check if there is a default constructed value and noop the destructor.
1 parent 80912a6 commit ad3dfb3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/transform-sdk/js/js_vm.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ value& value::operator=(const value& other) noexcept {
6969
}
7070

7171
value::~value() noexcept {
72-
// There is a bug with clang tidy where thinks that it's possible for _ctx
73-
// to be uninitialized when destructed inside of std::expected
74-
75-
// NOLINTNEXTLINE
76-
JS_FreeValue(_ctx, _underlying);
72+
if (_ctx != nullptr) {
73+
JS_FreeValue(_ctx, _underlying);
74+
}
7775
}
7876

7977
value value::undefined(JSContext* ctx) { return {ctx, JS_UNDEFINED}; }

0 commit comments

Comments
 (0)