maraiah: remove use of uninitialized memory
parent
7cbb5a1510
commit
666b9a78ec
|
@ -29,8 +29,7 @@ pub fn read(fp: &mut impl Read) -> ResultS<Collections>
|
||||||
let mut b = Vec::new();
|
let mut b = Vec::new();
|
||||||
fp.read_to_end(&mut b)?;
|
fp.read_to_end(&mut b)?;
|
||||||
|
|
||||||
// hush little rustc, don't say a word...
|
let mut collections = vec![(None, None); 32];
|
||||||
let mut collections: Collections = unsafe {std::mem::uninitialized()};
|
|
||||||
|
|
||||||
for (i, co) in collections.iter_mut().enumerate() {
|
for (i, co) in collections.iter_mut().enumerate() {
|
||||||
read_data! {
|
read_data! {
|
||||||
|
@ -55,6 +54,6 @@ pub fn read(fp: &mut impl Read) -> ResultS<Collections>
|
||||||
pub type CollectionDef = (Option<coll::Collection>, Option<coll::Collection>);
|
pub type CollectionDef = (Option<coll::Collection>, Option<coll::Collection>);
|
||||||
|
|
||||||
/// The set of all collections in a Shapes file.
|
/// The set of all collections in a Shapes file.
|
||||||
pub type Collections = [CollectionDef; 32];
|
pub type Collections = Vec<CollectionDef>;
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl Image for ImageShp<'_, '_>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An unpacked Shape bitmap.
|
/// An unpacked Shape bitmap.
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Bitmap {
|
pub struct Bitmap {
|
||||||
w: usize,
|
w: usize,
|
||||||
h: usize,
|
h: usize,
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn read(b: &[u8]) -> ResultS<Collection>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of color tables, bitmaps, frames and sequences.
|
/// A collection of color tables, bitmaps, frames and sequences.
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Collection {
|
pub struct Collection {
|
||||||
/// The type of collection this is.
|
/// The type of collection this is.
|
||||||
pub ctyp: CollectionType,
|
pub ctyp: CollectionType,
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn read(b: &[u8]) -> ResultS<Frame>
|
||||||
|
|
||||||
/// A frame, also known as a low level shape.
|
/// A frame, also known as a low level shape.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
/// The flags for this frame.
|
/// The flags for this frame.
|
||||||
pub flags: FrameFlags,
|
pub flags: FrameFlags,
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn read(b: &[u8]) -> ResultS<Sequence>
|
||||||
|
|
||||||
/// A sequence, also known as a high level shape.
|
/// A sequence, also known as a high level shape.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Sequence {
|
pub struct Sequence {
|
||||||
/// The display name for this sequence.
|
/// The display name for this sequence.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
Loading…
Reference in New Issue