From aedcc56b81d7fb0276f20d9b8890c39ebfc32e88 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 13 Jan 2022 13:26:44 -0500 Subject: [PATCH] layouter: handle width=0 gracefully --- src/proc/layouter.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proc/layouter.rs b/src/proc/layouter.rs index 5f6559f08e..39e8177eeb 100644 --- a/src/proc/layouter.rs +++ b/src/proc/layouter.rs @@ -74,7 +74,7 @@ impl Layouter { let layout = match ty.inner { Ti::Scalar { width, .. } | Ti::Atomic { width, .. } => TypeLayout { size, - alignment: Alignment::new(width as u32).unwrap(), + alignment: Alignment::new(width as u32).ok_or(InvalidBaseType(ty_handle))?, }, Ti::Vector { size: vec_size, @@ -88,7 +88,7 @@ impl Layouter { } else { 2 }; - Alignment::new((count * width) as u32).unwrap() + Alignment::new((count * width) as u32).ok_or(InvalidBaseType(ty_handle))? }, }, Ti::Matrix { @@ -99,7 +99,7 @@ impl Layouter { size, alignment: { let count = if rows >= crate::VectorSize::Tri { 4 } else { 2 }; - Alignment::new((count * width) as u32).unwrap() + Alignment::new((count * width) as u32).ok_or(InvalidBaseType(ty_handle))? }, }, Ti::Pointer { .. } | Ti::ValuePointer { .. } => TypeLayout {