From f776a0799429c6dd59444d5b9bfd877fe7b1c078 Mon Sep 17 00:00:00 2001 From: Georg Kunze Date: Mon, 16 Sep 2024 19:22:14 +0200 Subject: [PATCH] fix out of bounds array access in TilingParameters::bufferSizeOfLeaf() --- cinnamon/lib/Dialect/Cinm/Interfaces/TilingInterface.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cinnamon/lib/Dialect/Cinm/Interfaces/TilingInterface.cpp b/cinnamon/lib/Dialect/Cinm/Interfaces/TilingInterface.cpp index 05832fa..f934c6b 100644 --- a/cinnamon/lib/Dialect/Cinm/Interfaces/TilingInterface.cpp +++ b/cinnamon/lib/Dialect/Cinm/Interfaces/TilingInterface.cpp @@ -118,9 +118,10 @@ int64_t TilingParameters::bufferSizeOfLeaf() { int64_t bufSize = 0; int i = 0; do { - int lastIdx = bufferSizesInBytes.size() - 1 - i; + size_t lastIdx = bufferSizesInBytes.size() - 1 - i; bufSize += bufferSizesInBytes[lastIdx] / numLeafsInDim; - numLeafsInDim *= workgroupShape[lastIdx]; + numLeafsInDim *= + lastIdx < workgroupShape.size() ? workgroupShape[lastIdx] : 1; i++; } while (i < static_cast(bufferSizesInBytes.size())); return bufSize;