From b7882fb9847afc751c082e4679ac9c1867f86dbe Mon Sep 17 00:00:00 2001 From: geeknik <466878+geeknik@users.noreply.github.com> Date: Sun, 13 Aug 2023 14:35:14 +0000 Subject: [PATCH] Update hex.h Probably fixes #10 --- hex.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hex.h b/hex.h index 5514d90..7f1e70f 100644 --- a/hex.h +++ b/hex.h @@ -15,7 +15,10 @@ static const char hex_table[256] = { static inline int char_to_hex(unsigned char *val, int c) { - if (hex_table[(int)c] || c == '0') { + if (c < 0 || c > 255) { + return 0; // or handle the error as appropriate for your application + } + if (hex_table[c] || c == '0') { *val = hex_table[c]; return 1; }