From aea7c88dc92fbc701de87df6f77d87721b53b180 Mon Sep 17 00:00:00 2001 From: SHELL Team Date: Tue, 24 Mar 2026 14:07:06 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 888846457 --- shell_encryption/rns/rns_polynomial_hwy.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell_encryption/rns/rns_polynomial_hwy.cc b/shell_encryption/rns/rns_polynomial_hwy.cc index a90ad3e..89e497f 100644 --- a/shell_encryption/rns/rns_polynomial_hwy.cc +++ b/shell_encryption/rns/rns_polynomial_hwy.cc @@ -112,9 +112,11 @@ void BatchFusedMulAddMontgomeryRepHwy(absl::Span a, // Generate the masks on the even lanes, which correspond to the lower 64 bits // of BigInt64 (unsigned 128-bit int) values in the output vector. - uint8_t* mask_lo_bits = new uint8_t[(N + 7) / 8]; - for (int j = 0; j < (N + 7) / 8; ++j) { - mask_lo_bits[j] = 0; + // LoadMaskBits requires at least 8 readable bytes, even if N is small. + int num_bytes = (N + 7) / 8; + int alloc_bytes = num_bytes < 8 ? 8 : num_bytes; + uint8_t* mask_lo_bits = new uint8_t[alloc_bytes](); + for (int j = 0; j < num_bytes; ++j) { for (int k = 0; k < 8; k += 2) { mask_lo_bits[j] |= static_cast(1 << k); }