From 117ca03c968b47feeee4a6d2c817dd044a45eec7 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 17 Oct 2022 00:04:08 -0500 Subject: [PATCH] Fixed memory buffer overflow and read the last value Co-authored-by: sigonasr2 --- TMXParser.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TMXParser.h b/TMXParser.h index b5bd402..842da34 100644 --- a/TMXParser.h +++ b/TMXParser.h @@ -127,6 +127,7 @@ class TMXParser{ while (f.good()) { std::string data; f>>data; + if (data.empty()) continue; if (accumulator.length()>0) { //We're accumulating strings until we find '>' @@ -148,6 +149,9 @@ class TMXParser{ data = data.substr(data.find(",")+1,std::string::npos); rowData.push_back(stoi(datapiece)); } + if (data.length()) { + rowData.push_back(stoi(data)); + } parsedMapInfo.LayerData[parsedMapInfo.LayerData.size()-1].tiles.push_back(rowData); } }