Skip to content

Commit

Permalink
Fixed issue accessing uninitialized data when combining RTF output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Nov 2, 2014
1 parent c83db38 commit e5076ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/rtfgen.cpp
Expand Up @@ -2268,11 +2268,12 @@ bool isLeadBytes(int c)


// note: function is not reentrant!
static void encodeForOutput(FTextStream &t,const QCString &s)
static void encodeForOutput(FTextStream &t,const char *s)
{
if (s==0) return;
QCString encoding;
bool converted=FALSE;
int l = s.length();
int l = qstrlen(s);
static QByteArray enc;
if (l*4>(int)enc.size()) enc.resize(l*4); // worst case
encoding.sprintf("CP%s",theTranslator->trRTFansicp().data());
Expand All @@ -2284,7 +2285,7 @@ static void encodeForOutput(FTextStream &t,const QCString &s)
{
size_t iLeft=l;
size_t oLeft=enc.size();
char *inputPtr = s.data();
char *inputPtr = (char*)s;
char *outputPtr = enc.data();
if (!portable_iconv(cd, &inputPtr, &iLeft, &outputPtr, &oLeft))
{
Expand All @@ -2296,7 +2297,7 @@ static void encodeForOutput(FTextStream &t,const QCString &s)
}
if (!converted) // if we did not convert anything, copy as is.
{
memcpy(enc.data(),s.data(),l);
memcpy(enc.data(),s,l);
enc.resize(l);
}
uint i;
Expand Down Expand Up @@ -2355,7 +2356,7 @@ static bool preProcessFile(QDir &d,QCString &infName, FTextStream &t, bool bIncl
err("read error in %s before end of RTF header!\n",infName.data());
return FALSE;
}
if (bIncludeHeader) encodeForOutput(t,lineBuf);
if (bIncludeHeader) encodeForOutput(t,lineBuf.data());
} while (lineBuf.find("\\comment begin body")==-1);


Expand Down

0 comments on commit e5076ed

Please sign in to comment.