Fix check for malformed input when decoding translations

Any integer modulo 1 can never be anything else but 0, so the statement
could never be true. The intention is to abort in case of an odd number
of bytes, as this would indicate malformed input that can't be decoded
into a QString.

Note that QTranslator will then silently continue to search for valid
translations, and not print any error message at runtime, or otherwise
inform the user or developer that an input message file contains
malformed content.

Change-Id: I957b337ee035f3aca013e0859f8ee70553d9a97b
Coverity-Id: 11014
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
Volker Hilsheimer 2020-06-04 10:37:59 +02:00
parent a389001710
commit 458d49861f

View File

@ -911,7 +911,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
goto end;
case Tag_Translation: {
int len = read32(m);
if (len % 1)
if (len & 1)
return QString();
m += 4;
if (!numerus--) {