diff options
author | Jihoon Kim <jihoon48.kim@samsung.com> | 2024-02-13 10:33:20 +0900 |
---|---|---|
committer | Jihoon Kim <jihoon48.kim@samsung.com> | 2024-02-19 14:36:46 +0900 |
commit | 63d9d57f04c1b16e370fa28b328fc33489819e07 (patch) | |
tree | f203bb524a1d391d1e26b25fcfe9cb25a1c2285b | |
parent | f00e4d030c9dd49e40a8fa08fcae0c1a1be5cf14 (diff) | |
download | libxkbcommon-63d9d57f04c1b16e370fa28b328fc33489819e07.tar.gz libxkbcommon-63d9d57f04c1b16e370fa28b328fc33489819e07.tar.bz2 libxkbcommon-63d9d57f04c1b16e370fa28b328fc33489819e07.zip |
Fix issues detected by static analysis toolaccepted/tizen/unified/x/20240220.150017accepted/tizen/unified/toolchain/20240311.070033accepted/tizen/unified/dev/20240620.010903accepted/tizen/unified/20240219.160452accepted/tizen_unified_dev
Change-Id: I1dc356839dd3af7141df7dc727d58aa782b69da0
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
-rw-r--r-- | src/scanner-utils.h | 5 | ||||
-rw-r--r-- | test/common.c | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/scanner-utils.h b/src/scanner-utils.h index e6cd192..3be8392 100644 --- a/src/scanner-utils.h +++ b/src/scanner-utils.h @@ -203,14 +203,13 @@ 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); - result = *out * 16 + c - offset; - *out = (uint8_t)result; + if (*out * 16 + c >= offset) + *out = *out * 16 + c - offset; } return i > 0; } diff --git a/test/common.c b/test/common.c index cb911e8..0bed3de 100644 --- a/test/common.c +++ b/test/common.c @@ -260,7 +260,7 @@ test_read_file(const char *path_rel) remaining = info.st_size; tmp = ret; - while ((count = read(fd, tmp, remaining))) { + while ((count = read(fd, tmp, remaining)) > 0) { remaining -= count; tmp += count; } |