Skip to content

Commit 029cef4

Browse files
committed
transform-sdk/js: fix asan violations for assignment operators
1 parent a584e7f commit 029cef4

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/transform-sdk/cpp/BUILD

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
cc_library(
2-
name = "transform-sdk",
2+
name = "transform_sdk",
33
srcs = ["src/transform_sdk.cc"],
44
hdrs = ["include/redpanda/transform_sdk.h"],
55
copts = [
66
"-std=c++23",
77
"-fno-exceptions",
88
],
99
includes = ["include"],
10+
visibility = ["//visibility:public"],
1011
)

src/transform-sdk/js/BUILD

+13
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@ cc_test(
2222
"@googletest//:gtest_main",
2323
],
2424
)
25+
26+
cc_binary(
27+
name = "main",
28+
srcs = ["main.cc"],
29+
copts = [
30+
"-std=c++23",
31+
"-fno-exceptions",
32+
],
33+
deps = [
34+
":js_vm",
35+
"//src/transform-sdk/cpp:transform_sdk",
36+
],
37+
)

src/transform-sdk/js/js_vm.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ value& value::operator=(value&& other) noexcept {
4848
if (this == &other) {
4949
return *this;
5050
}
51-
JS_FreeValue(_ctx, _underlying);
51+
if (_ctx != nullptr) {
52+
JS_FreeValue(_ctx, _underlying);
53+
}
5254
_ctx = std::exchange(other._ctx, nullptr);
5355
_underlying = std::exchange(other._underlying, JS_UNINITIALIZED);
5456
return *this;
@@ -62,7 +64,9 @@ value& value::operator=(const value& other) noexcept {
6264
if (this == &other) {
6365
return *this;
6466
}
65-
JS_FreeValue(_ctx, _underlying);
67+
if (_ctx != nullptr) {
68+
JS_FreeValue(_ctx, _underlying);
69+
}
6670
_ctx = other._ctx;
6771
_underlying = other.raw_dup();
6872
return *this;

0 commit comments

Comments
 (0)