From fe6fff14d16a810bcddf45c3a301e646ca990687 Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Tue, 24 Feb 2015 17:16:52 +0100 Subject: [PATCH] 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. --- src/sds.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sds.c b/src/sds.c index 6e7a03de..c025cfe7 100644 --- a/src/sds.c +++ b/src/sds.c @@ -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);