Skip to content

Commit

Permalink
sds: fix double lookup of int2hex (#1995)
Browse files Browse the repository at this point in the history
After int2hex lookup, c is greater than or equal to '0' = 48, so in the
second lookup, it overruns the int2hex array.

Signed-off-by: Zero King <[email protected]>
  • Loading branch information
l2dy authored and edsiper committed Mar 5, 2020
1 parent 8d1ae9f commit 2a82db5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/flb_sds.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ flb_sds_t flb_sds_cat_utf8 (flb_sds_t *sds, const char *str, int str_len)
s[head->len++] = '\\';
s[head->len++] = 'u';
if (cp > 0xFFFF) {
c = int2hex[ (unsigned char) ((cp & 0xf00000) >> 20)];
c = (unsigned char) ((cp & 0xf00000) >> 20);
if (c > 0) {
s[head->len++] = int2hex[c];
}
c = int2hex[ (unsigned char) ((cp & 0x0f0000) >> 16)];
c = (unsigned char) ((cp & 0x0f0000) >> 16);
if (c > 0) {
s[head->len++] = int2hex[c];
}
Expand Down

0 comments on commit 2a82db5

Please sign in to comment.