qjson: add missed Q_CHECK_PTR

There might be dereferencing of a potential null pointer 'h'

Task-number: QTBUG-71156
Change-Id: I63c34f8cba3e358f109d70ff9b34199c31895202
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
bb10
Ivan Komissarov 2018-10-20 17:28:18 +02:00
parent 9ef793ba95
commit c6c31b14a7
2 changed files with 2 additions and 0 deletions

View File

@ -70,6 +70,7 @@ void Data::compact()
int size = sizeof(Base) + reserve + base->length*sizeof(offset);
int alloc = sizeof(Header) + size;
Header *h = (Header *) malloc(alloc);
Q_CHECK_PTR(h);
h->tag = QJsonDocument::BinaryFormatTag;
h->version = 1;
Base *b = h->root();

View File

@ -304,6 +304,7 @@ QJsonDocument Parser::parse(QJsonParseError *error)
// allocate some space
dataLength = qMax(end - json, (ptrdiff_t) 256);
data = (char *)malloc(dataLength);
Q_CHECK_PTR(data);
// fill in Header data
QJsonPrivate::Header *h = (QJsonPrivate::Header *)data;