Fuzzing: Don't copy input data to QByteArray

Change-Id: I603413805dca46a85709c2ab6ff573687849572e
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
This commit is contained in:
Robert Loehning 2019-10-04 14:59:02 +02:00
parent 5e7365573e
commit d6734e8ab7
4 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
QXmlStreamReader reader(QByteArray(Data, Size)); QXmlStreamReader reader(QByteArray::fromRawData(Data, Size));
while (!reader.atEnd()) while (!reader.atEnd())
reader.readNext(); reader.readNext();
return 0; return 0;

View File

@ -32,6 +32,6 @@
extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) {
static int c = 0; static int c = 0;
static QGuiApplication a(c, nullptr); static QGuiApplication a(c, nullptr);
QColorSpace cs = QColorSpace::fromIccProfile(QByteArray(data, size)); QColorSpace cs = QColorSpace::fromIccProfile(QByteArray::fromRawData(data, size));
return 0; return 0;
} }

View File

@ -32,6 +32,6 @@
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
static int c = 0; static int c = 0;
static QApplication a(c, nullptr); static QApplication a(c, nullptr);
QTextDocument().setHtml(QByteArray(Data, Size)); QTextDocument().setHtml(QByteArray::fromRawData(Data, Size));
return 0; return 0;
} }

View File

@ -29,6 +29,6 @@
#include <QTextDocument> #include <QTextDocument>
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
QTextDocument().setMarkdown(QByteArray(Data, Size)); QTextDocument().setMarkdown(QByteArray::fromRawData(Data, Size));
return 0; return 0;
} }