Skip to content

Commit e55a280

Browse files
committed
Fixes #655
1 parent cf55347 commit e55a280

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

imageflow_core/src/ffi.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub const FILTER_OPTIONS: &'static [&'static str] = &["robidouxfast",
131131

132132

133133

134-
134+
/// Not for external use
135135
#[repr(C)]
136136
#[derive(Clone,Debug,PartialEq)]
137137
pub struct BitmapBgra {
@@ -237,11 +237,19 @@ impl BitmapBgra {
237237
Ok(())
238238
}
239239

240+
pub fn is_pointer_null(&self) -> bool{
241+
self.pixels.is_null()
242+
}
243+
240244
/// Call normalize_alpha first; this function does not skip unused alpha bytes, only unused whole pixels.
241245
/// Otherwise Bgr32 may be non-deterministic
242-
pub fn short_hash_pixels(&self) -> u64{
246+
pub unsafe fn short_hash_pixels(&self) -> u64{
243247
use std::hash::Hasher;
244248

249+
if self.is_pointer_null(){
250+
panic!("BitmapBgra::short_hash_pixels called on invalid pointer");
251+
}
252+
245253
let width_bytes = self.w as usize * self.fmt.bytes();
246254

247255
let mut hash = ::twox_hash::XxHash::with_seed(0x8ed1_2ad9_483d_28a0);

0 commit comments

Comments
 (0)