don't segfault if MagickGetImageBlob returns null
This commit is contained in:
@ -831,6 +831,9 @@ impl MagickWand {
|
|||||||
bindings::MagickSetImageFormat(self.wand, c_format.as_ptr());
|
bindings::MagickSetImageFormat(self.wand, c_format.as_ptr());
|
||||||
bindings::MagickGetImageBlob(self.wand, &mut length)
|
bindings::MagickGetImageBlob(self.wand, &mut length)
|
||||||
};
|
};
|
||||||
|
if blob.is_null() {
|
||||||
|
Err(MagickError("failed to write image blob"))
|
||||||
|
} else {
|
||||||
let mut bytes = Vec::with_capacity(length as usize);
|
let mut bytes = Vec::with_capacity(length as usize);
|
||||||
unsafe {
|
unsafe {
|
||||||
bytes.set_len(length as usize);
|
bytes.set_len(length as usize);
|
||||||
@ -839,6 +842,7 @@ impl MagickWand {
|
|||||||
};
|
};
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Write the images in the desired format to a new blob.
|
/// Write the images in the desired format to a new blob.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user