Skip to content

Commit

Permalink
Update hex.h
Browse files Browse the repository at this point in the history
Probably fixes damus-io#10
  • Loading branch information
geeknik authored Aug 13, 2023
1 parent 1b389a8 commit b7882fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit b7882fb

Please sign in to comment.