pic: Fix Invalid-enum-value undefined behaviour

Summary:
Instead of directly casting the quint8 to PicChannelEncoding we just store the quint8
and compare it to the possible PicChannelEncoding values when needed

oss-fuzz/19344

Reviewers: dfaure

Reviewed By: dfaure

Subscribers: dfaure, security-team, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D25937
This commit is contained in:
Albert Astals Cid 2019-12-14 21:04:46 +01:00
parent 69effbf9f5
commit f03739f222
2 changed files with 2 additions and 4 deletions

View File

@ -130,9 +130,7 @@ static QDataStream &operator>> (QDataStream &s, QList<PicChannel> &channels)
PicChannel channel;
s >> chained;
s >> channel.size;
quint8 encoding;
s >> encoding;
channel.encoding = PicChannelEncoding(encoding);
s >> channel.encoding;
s >> channel.code;
channels << channel;
++count;

View File

@ -119,7 +119,7 @@ struct PicHeader {
*/
struct PicChannel {
quint8 size; /**< Bits per component per pixel. */
PicChannelEncoding encoding; /**< How the channel's data is encoded. */
quint8 encoding; /**< How the channel's data is encoded. */
quint8 code; /**< Flag field to describe which components are encoded in
this channel. */