From 959de6f4c15d537e45e09cfad37c5fcaf1810bca Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 17 Feb 2023 22:56:56 +0100 Subject: [PATCH] Avoid UB on empty fog data record --- components/esm3/fogstate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esm3/fogstate.cpp b/components/esm3/fogstate.cpp index 4f25c33c13..65f391cefb 100644 --- a/components/esm3/fogstate.cpp +++ b/components/esm3/fogstate.cpp @@ -69,9 +69,9 @@ namespace ESM esm.getT(tex.mX); esm.getT(tex.mY); - size_t imageSize = esm.getSubSize() - sizeof(int) * 2; + const std::size_t imageSize = esm.getSubSize() - sizeof(int) * 2; tex.mImageData.resize(imageSize); - esm.getExact(&tex.mImageData[0], imageSize); + esm.getExact(tex.mImageData.data(), imageSize); if (dataFormat <= MaxOldForOfWarFormatVersion) convertFogOfWar(tex.mImageData); @@ -92,7 +92,7 @@ namespace ESM esm.startSubRecord("FTEX"); esm.writeT(it->mX); esm.writeT(it->mY); - esm.write(&it->mImageData[0], it->mImageData.size()); + esm.write(it->mImageData.data(), it->mImageData.size()); esm.endRecord("FTEX"); } }