summaryrefslogtreecommitdiffstats
path: root/toolkit/components/uniffi-js/OwnedRustBuffer.cpp
diff options
context:
space:
mode:
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);
});
}