redlis-cli crash on non-printable chars
The debug version of isprint() raises an assert when the input value is not EOF or in the range 0 through 0xFF, inclusive. The trick is that the char value needs to be passed as unsigned, before being converted to int.
This commit is contained in:
@@ -771,7 +771,11 @@ sds sdscatrepr(sds s, const char *p, size_t len) {
|
||||
case '\a': s = sdscatlen(s,"\\a",2); break;
|
||||
case '\b': s = sdscatlen(s,"\\b",2); break;
|
||||
default:
|
||||
#ifdef _WIN32
|
||||
if (isprint((unsigned char)*p))
|
||||
#else
|
||||
if (isprint(*p))
|
||||
#endif
|
||||
s = sdscatprintf(s,"%c",*p);
|
||||
else
|
||||
s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
|
||||
|
||||
Reference in New Issue
Block a user