diff options
Diffstat (limited to 'src/scanner-utils.h')
-rw-r--r-- | src/scanner-utils.h | 5 |
1 files changed, 2 insertions, 3 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; } |