From 155664a085bec03623dd497c611111e54766d305 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 25 Sep 2007 08:00:46 +0000 Subject: Make formatted_string::parse_string() split up the string into chunks of 999 characters or less so that formatted_string::cprintf()'s character buffer doesn't overflow. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2199 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/format.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crawl-ref/source/format.cc') diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 595d2a3f85..400f900dff 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -74,6 +74,18 @@ formatted_string formatted_string::parse_string( bool invert_colour = false; std::string::size_type endpos = std::string::npos; + // Break string up if it gets too big. + if (currs.size() >= 999) + { + fs.cprintf(currs.substr(0, 999)); + if (currs.size() > 999) + currs = currs.substr(999); + else + currs.clear(); + tag--; + continue; + } + if (s[tag] != '<' || tag >= length - 2) { if (!masked) -- cgit v1.2.3-54-g00ecf