Skip to content

Commit 550c4f5

Browse files
authored
fix: ensure we associate correct memory for the user_metadata attached to a cache item (#734)
1 parent ad6b607 commit 550c4f5

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

runtime/js-compute-runtime/builtins/cache-core.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ JS::Result<host_api::CacheWriteOptions> parseTransactionUpdateOptions(JSContext
263263
size_t length;
264264
JS::UniqueChars data;
265265
std::tie(data, length) = result.unwrap();
266-
host_api::HostBytes metadata(std::move(data), length);
267-
options.metadata = std::move(metadata);
266+
options.metadata = host_api::HostBytes(std::move(data), length);
268267
}
269268

270269
return options;

runtime/js-compute-runtime/host_interface/host_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ void init_write_options(fastly_compute_at_edge_cache_write_options_t &options,
13701370

13711371
options.length = opts.length;
13721372

1373-
if (opts.metadata.empty()) {
1373+
if (!opts.metadata.len || !opts.metadata.ptr) {
13741374
options.user_metadata.ptr = 0;
13751375
options.user_metadata.len = 0;
13761376
} else {

runtime/js-compute-runtime/host_interface/host_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ struct CacheWriteOptions final {
679679

680680
uint64_t length = 0;
681681

682-
std::span<uint8_t> metadata;
682+
HostBytes metadata;
683683

684684
bool sensitive = false;
685685
};

0 commit comments

Comments
 (0)