rust: bssl-tls: Clean up all slice_from_raw_parts I forgot about this macro and I did not check it. Signed-off-by: Xiangfei Ding <xfding@google.com> Change-Id: I39957db647c88265ed91433974b56df26a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/100107 Reviewed-by: Rudolf Polzer <rpolzer@google.com>
diff --git a/rust/bssl-tls/src/macros.rs b/rust/bssl-tls/src/macros.rs index d9fb5ae..3b6a19a 100644 --- a/rust/bssl-tls/src/macros.rs +++ b/rust/bssl-tls/src/macros.rs
@@ -94,14 +94,13 @@ ) }; if data.is_null() || len == 0 || len > isize::MAX as usize { - &[] - } else { - unsafe { - // Safety: - // - `data` is 1-size and 1-align and `len` is valid by BoringSSL invariant. - // - `len` is sanitised to be within bound. - ::core::slice::from_raw_parts(data, len) - } + return &[] + } + unsafe { + // Safety: + // - `data` is 1-size and 1-align and `len` is valid by BoringSSL invariant. + // - `len` is sanitised to be within bound. + $crate::ffi::sanitize_slice(data, len).unwrap_or(&[]) } } }