From ed910c0bebea03a27344822536168e466b46a7b1 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 13 Dec 2024 22:24:58 -0600 Subject: [PATCH] [nostalgia/core/studio/tilesheeteditor] Fix access overflow on out of bounds Fill command --- .../studio/tilesheeteditor/tilesheeteditormodel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp index 15811e77..c16e51a8 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp @@ -190,16 +190,16 @@ void TileSheetEditorModel::setActiveSubsheet(TileSheet::SubSheetIdx const&idx) n } void TileSheetEditorModel::fill(ox::Point const&pt, int palIdx) noexcept { - const auto &s = getSubSheet(m_img, m_activeSubsSheetIdx); + auto const&activeSubSheet = getSubSheet(m_img, m_activeSubsSheetIdx); // build idx list - ox::Array updateMap = {}; - const auto oldColor = getPixel(s, m_img.bpp, pt); - if (pt.x >= s.columns * TileWidth || pt.y >= s.rows * TileHeight) { + if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) { return; } + ox::Array updateMap = {}; + auto const oldColor = getPixel(activeSubSheet, m_img.bpp, pt); getFillPixels(updateMap, pt, oldColor); ox::Vector idxList; - auto i = core::idx(s, pt) / PixelsPerTile * PixelsPerTile; + auto i = core::idx(activeSubSheet, pt) / PixelsPerTile * PixelsPerTile; for (auto u : updateMap) { if (u) { idxList.emplace_back(i); @@ -209,7 +209,7 @@ void TileSheetEditorModel::fill(ox::Point const&pt, int palIdx) noexcept { // do updates to sheet if (m_ongoingDrawCommand) { m_updated = m_updated || m_ongoingDrawCommand->append(idxList); - } else if (getPixel(s, m_img.bpp, pt) != palIdx) { + } else if (getPixel(activeSubSheet, m_img.bpp, pt) != palIdx) { pushCommand(ox::make(m_img, m_activeSubsSheetIdx, idxList, palIdx)); } }