Fix uninitialized memory read

Summary:
Make sure whole of pixel_size in pixel has data either because it was
read or because we set it to 0

oss-fuzz/14565

Reviewers: dfaure, apol, vkrause

Reviewed By: vkrause

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D23739
This commit is contained in:
Albert Astals Cid 2019-09-05 20:05:29 +02:00
parent 40353da5db
commit 4bf2894bde

View File

@ -252,7 +252,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
// RLE pixels.
assert(pixel_size <= 8);
char pixel[8];
s.readRawData(pixel, pixel_size);
const int dataRead = s.readRawData(pixel, pixel_size);
if (dataRead < (int)pixel_size) {
memset(&pixel[dataRead], 0, pixel_size - dataRead);
}
do {
memcpy(dst, pixel, pixel_size);
dst += pixel_size;