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