summaryrefslogtreecommitdiffstats
path: root/toolkit/components/uniffi-js/OwnedRustBuffer.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /toolkit/components/uniffi-js/OwnedRustBuffer.cpp
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/uniffi-js/OwnedRustBuffer.cpp')
-rw-r--r--toolkit/components/uniffi-js/OwnedRustBuffer.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/toolkit/components/uniffi-js/OwnedRustBuffer.cpp b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp
index f14033a213..7bcf8a81a2 100644
--- a/toolkit/components/uniffi-js/OwnedRustBuffer.cpp
+++ b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp
@@ -11,8 +11,7 @@ namespace mozilla::uniffi {
using dom::ArrayBuffer;
-OwnedRustBuffer::OwnedRustBuffer(const RustBuffer& aBuf) {
- mBuf = aBuf;
+OwnedRustBuffer::OwnedRustBuffer(const RustBuffer& aBuf) : mBuf(aBuf) {
MOZ_ASSERT(IsValid());
}
@@ -21,14 +20,11 @@ Result<OwnedRustBuffer, nsCString> OwnedRustBuffer::FromArrayBuffer(
return aArrayBuffer.ProcessData(
[](const Span<uint8_t>& aData,
JS::AutoCheckCannotGC&&) -> Result<OwnedRustBuffer, nsCString> {
- if (aData.Length() > INT32_MAX) {
- return Err("Input ArrayBuffer is too large"_ns);
- }
-
+ uint64_t bufLen = aData.Length();
RustCallStatus status{};
- RustBuffer buf = uniffi_rustbuffer_alloc(
- static_cast<uint64_t>(aData.Length()), &status);
- buf.len = aData.Length();
+ RustBuffer buf =
+ uniffi_rustbuffer_alloc(static_cast<uint64_t>(bufLen), &status);
+ buf.len = bufLen;
if (status.code != 0) {
if (status.error_buf.data) {
auto message = nsCString("uniffi_rustbuffer_alloc: ");
@@ -45,7 +41,7 @@ Result<OwnedRustBuffer, nsCString> OwnedRustBuffer::FromArrayBuffer(
return Err("Unknown error allocating rust buffer"_ns);
}
- memcpy(buf.data, aData.Elements(), buf.len);
+ memcpy(buf.data, aData.Elements(), bufLen);
return OwnedRustBuffer(buf);
});
}