From bc8e705cf90cecdff8a247264c249ffed1d2af4a Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 3 Jan 2015 17:49:57 +0100 Subject: [PATCH] Correct string buffer sizes for RTF output, such that the string is always correctly sized. --- src/rtfgen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 0c27089b255..3f09eec3b23 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -2365,17 +2365,21 @@ static bool preProcessFile(QDir &d,QCString &infName, FTextStream &t, bool bIncl int len; do { + lineBuf.resize(maxLineLength); if ((len=f.readLine(lineBuf.rawData(),maxLineLength))==-1) { err("read error in %s before end of RTF header!\n",infName.data()); return FALSE; } + lineBuf.resize(len+1); if (bIncludeHeader) encodeForOutput(t,lineBuf.data()); } while (lineBuf.find("\\comment begin body")==-1); + lineBuf.resize(maxLineLength); while ((len=f.readLine(lineBuf.rawData(),maxLineLength))!=-1) { + lineBuf.resize(len+1); int pos; if ((pos=lineBuf.find("INCLUDETEXT"))!=-1) { @@ -2407,6 +2411,7 @@ static bool preProcessFile(QDir &d,QCString &infName, FTextStream &t, bool bIncl encodeForOutput(t,lineBuf); } } + lineBuf.resize(maxLineLength); } f.close(); // remove temporary file