From: Jihoon Kim Date: Mon, 29 Jan 2024 11:44:12 +0000 (+0900) Subject: Fix overflow issue X-Git-Tag: accepted/tizen/unified/20240131.064100^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=f00e4d030c9dd49e40a8fa08fcae0c1a1be5cf14;p=platform%2Fupstream%2Flibxkbcommon.git Fix overflow issue Overflowed constant (INTEGER_OVERFLOW) overflow_const: Expression *out, which is equal to 3161, where *out * 16 + c - offset is known to be equal to 89, overflows the type that receives it, an unsigned integer 8 bits wide. Change-Id: I81fc7a20558c9b78f5c56647ae99c65189e42360 Signed-off-by: Jihoon Kim --- diff --git a/src/scanner-utils.h b/src/scanner-utils.h index 674ecaa..e6cd192 100644 --- a/src/scanner-utils.h +++ b/src/scanner-utils.h @@ -203,11 +203,14 @@ static inline bool scanner_hex(struct scanner *s, uint8_t *out) { int i; + unsigned int result = 0; for (i = 0, *out = 0; is_xdigit(scanner_peek(s)) && i < 2; i++) { const char c = scanner_next(s); const char offset = (c >= '0' && c <= '9' ? '0' : c >= 'a' && c <= 'f' ? 'a' - 10 : 'A' - 10); - *out = *out * 16 + c - offset; + + result = *out * 16 + c - offset; + *out = (uint8_t)result; } return i > 0; }