summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/format.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-25 08:00:46 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-25 08:00:46 +0000
commit155664a085bec03623dd497c611111e54766d305 (patch)
treed695f26d8cb6c1ff5e21cf2568e98790d4e1cf89 /crawl-ref/source/format.cc
parenta2020fe249d7a1cfbcaf52bc8ed1333ca458ab89 (diff)
downloadcrawl-ref-155664a085bec03623dd497c611111e54766d305.tar.gz
crawl-ref-155664a085bec03623dd497c611111e54766d305.zip
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
Diffstat (limited to 'crawl-ref/source/format.cc')
-rw-r--r--crawl-ref/source/format.cc12
1 files changed, 12 insertions, 0 deletions
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)