QColor: Fix use of uninit'ed value in get_hex_rgb()
If len == 0, we didn't write anything to 'tmp', but get_hex_rgb()
unconditionally reads tmp[0] (aliased to name[0] in get_hex_rgb()).
Fix by terminating the tmp array, thus ensuring that the comparison
against '#' in get_hex_rgb() fails.
Introduced in a41393d0bc
.
Coverity-Id: 171477
Change-Id: I53952aff7035813ed6abc74d402953bc9cfa76f1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
f2b90b4e82
commit
483aff406a
@ -131,6 +131,7 @@ static bool get_hex_rgb(const QChar *str, int len, QRgb *rgb)
|
||||
char tmp[16];
|
||||
for (int i = 0; i < len; ++i)
|
||||
tmp[i] = str[i].toLatin1();
|
||||
tmp[len] = 0;
|
||||
return get_hex_rgb(tmp, len, rgb);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user