From 33b9fc4e062537a5ab8d4c60c72573f868ab3f13 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 14 Oct 2016 18:12:30 +0200 Subject: QTgaFile: fix Coverity warning re:mixing enum types Coverity complained that the 'bytes' variable was first compared to a QTgaFile::HeaderOffset, then, later, to a QTgaFile::FooterOffset. This is of course a false positive, but one that's trivial to fix, by not using a variable in the first place. Adjust to Qt coding standard as a drive-by. Coverity-Id: 22048 Change-Id: If1a45aa5b0c8ea23cab2cefeccb2f1dfe5f03375 Reviewed-by: Eirik Aavitsland --- src/plugins/imageformats/tga/qtgafile.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp index 14a7a74..e2f20a7 100644 --- a/src/plugins/imageformats/tga/qtgafile.cpp +++ b/src/plugins/imageformats/tga/qtgafile.cpp @@ -144,9 +144,7 @@ QTgaFile::QTgaFile(QIODevice *device) mErrorMessage = tr("Seek file/device for image read failed"); return; } - int bytes = device->read((char*)mHeader, HeaderSize); - if (bytes != HeaderSize) - { + if (device->read(reinterpret_cast(mHeader), HeaderSize) != HeaderSize) { mErrorMessage = tr("Image header read failed"); return; } @@ -170,9 +168,7 @@ QTgaFile::QTgaFile(QIODevice *device) return; } char footer[FooterSize]; - bytes = mDevice->read((char*)footer, FooterSize); - if (bytes != FooterSize) - { + if (mDevice->read(reinterpret_cast(footer), FooterSize) != FooterSize) { mErrorMessage = tr("Could not read footer"); } if (qstrncmp(&footer[SignatureOffset], "TRUEVISION-XFILE", 16) != 0) -- cgit v1.2.1 From 0870e670665a702665948723bb7b1eb61a9572a8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 14 Oct 2016 18:33:10 +0200 Subject: QWbmpHandler: fix integer overflow Both 'hdr.height' and 'hdr.width' are quint32s. Multiplying them still gives a quint32, but the lhs expected a qint64. Fix by casting one of the operands to qint64. Coverity-Id: 22179 Change-Id: If7385fb42bf994d87ac4e603fa85be4a30ad6d5c Reviewed-by: Eirik Aavitsland --- src/plugins/imageformats/wbmp/qwbmphandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/imageformats/wbmp/qwbmphandler.cpp b/src/plugins/imageformats/wbmp/qwbmphandler.cpp index 0d08422..5fe8ec9 100644 --- a/src/plugins/imageformats/wbmp/qwbmphandler.cpp +++ b/src/plugins/imageformats/wbmp/qwbmphandler.cpp @@ -244,7 +244,7 @@ bool WBMPReader::canRead(QIODevice *device) WBMPHeader hdr; if (readWBMPHeader(device, &hdr)) { if ((hdr.type == 0) && (hdr.format == 0)) { - qint64 imageSize = hdr.height * ((hdr.width + 7) / 8); + const qint64 imageSize = hdr.height * ((qint64(hdr.width) + 7) / 8); qint64 available = device->bytesAvailable(); device->seek(oldPos); return (imageSize == available); -- cgit v1.2.1