From 8b0ca4ef2ac6a57fd66371ac4c5b218efc14578c Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 9 Aug 2024 13:12:01 +0200 Subject: [PATCH] Have the same length==0 in value_blob as in value_text to avoid null access. --- src/api.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api.rs b/src/api.rs index 11e444f..a5ecadc 100644 --- a/src/api.rs +++ b/src/api.rs @@ -118,6 +118,9 @@ pub fn mprintf(base: &str) -> Result<*mut c_char, MprintfError> { /// from the given sqlite3_value, as a u8 slice. pub fn value_blob<'a>(value: &*mut sqlite3_value) -> &'a [u8] { let n = value_bytes(value); + if n == 0 { + return &[]; + } let b = unsafe { sqlite3ext_value_blob(value.to_owned()) }; return unsafe { from_raw_parts(b.cast::(), n as usize) }; }