PDF engine: handle abnormally long string cases
The output routine used a fixed size scratch buffer, with no attempt to handle overrun. Add a simple fallback code path for such (extremely rare) cases. Task-number: QTBUG-66788 Change-Id: I52531b829baeaa48a8fb5a637a020ee9f89d270a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>bb10
parent
7f782e1fc4
commit
ca58764da1
|
|
@ -2045,7 +2045,6 @@ void QPdfEnginePrivate::printString(const QString &string)
|
|||
}
|
||||
|
||||
|
||||
// For strings up to 10000 bytes only !
|
||||
void QPdfEnginePrivate::xprintf(const char* fmt, ...)
|
||||
{
|
||||
if (!stream)
|
||||
|
|
@ -2057,12 +2056,18 @@ void QPdfEnginePrivate::xprintf(const char* fmt, ...)
|
|||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int bufsize = qvsnprintf(buf, msize, fmt, args);
|
||||
|
||||
Q_ASSERT(bufsize<msize);
|
||||
|
||||
va_end(args);
|
||||
|
||||
stream->writeRawData(buf, bufsize);
|
||||
if (Q_LIKELY(bufsize < msize)) {
|
||||
stream->writeRawData(buf, bufsize);
|
||||
} else {
|
||||
// Fallback for abnormal cases
|
||||
QScopedArrayPointer<char> tmpbuf(new char[bufsize + 1]);
|
||||
va_start(args, fmt);
|
||||
bufsize = qvsnprintf(tmpbuf.data(), bufsize + 1, fmt, args);
|
||||
va_end(args);
|
||||
stream->writeRawData(tmpbuf.data(), bufsize);
|
||||
}
|
||||
streampos += bufsize;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue