From 4380a6c9f23a9d1f420844349c5485f438d88205 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 22 Mar 2021 23:32:55 +0100 Subject: [PATCH] Set last byte of rawfile buffer to 0 when loading asset --- src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp | 1 + src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp index 9e81d6a7..68b9d13f 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderRawFile.cpp @@ -34,6 +34,7 @@ bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath* file.m_stream->read(fileBuffer, file.m_length); if (file.m_stream->gcount() != file.m_length) return false; + fileBuffer[rawFile->len] = '\0'; rawFile->data.buffer = fileBuffer; manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp index 6786f993..a909ffcc 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderRawFile.cpp @@ -34,6 +34,7 @@ bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath* file.m_stream->read(fileBuffer, file.m_length); if (file.m_stream->gcount() != file.m_length) return false; + fileBuffer[rawFile->len] = '\0'; rawFile->buffer = static_cast(fileBuffer); manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile);