fix buffer sizes
authoralfadur
Sat, 03 Aug 2019 02:51:19 +0300
changeset 15309 0f734fa371e1
parent 15308 3bb3fe1cf87c
child 15310 fd20e0a134af
fix buffer sizes
rust/hwphysics/src/common.rs
rust/lib-hedgewars-engine/src/render/gear.rs
--- a/rust/hwphysics/src/common.rs	Sat Aug 03 02:14:07 2019 +0300
+++ b/rust/hwphysics/src/common.rs	Sat Aug 03 02:51:19 2019 +0300
@@ -114,7 +114,7 @@
 impl<T: Default + Copy> GearDataLookup<T> {
     pub fn new() -> Self {
         Self {
-            lookup: Vec::with_capacity(u16::max_value() as usize).into_boxed_slice()
+            lookup: vec![LookupEntry::default(); u16::max_value() as usize].into_boxed_slice(),
         }
     }
 }
--- a/rust/lib-hedgewars-engine/src/render/gear.rs	Sat Aug 03 02:14:07 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/render/gear.rs	Sat Aug 03 02:51:19 2019 +0300
@@ -48,7 +48,7 @@
 
         let texture = Texture2D::new(max_size, gl::RGBA8, gl::LINEAR);
 
-        let mut pixels = Vec::with_capacity(max_size.area()).into_boxed_slice();
+        let mut pixels = vec![0; max_size.area() * 4].into_boxed_slice();
         for (path, sprite_index) in lookup.drain(..) {
             if let Some((atlas_index, rect)) = atlas.get_rect(sprite_index) {
                 load_sprite_pixels(&path, &mut pixels[..]).expect("Unable to load Graphics");