From de9bae21efa2e14d71bdedb3326abacbb310135c Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Thu, 1 Jul 2021 08:19:04 +0300 Subject: [PATCH] Fix bug in sdscatfmt when % is the last format char (#9173) For the sdscatfmt function in sds.c, when the parameter fmt ended up with '%', the behavior is undefined. This commit fix this bug. Co-authored-by: stafuc --- src/sds.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sds.c b/src/sds.c index 036d714d41..e722abbcaa 100644 --- a/src/sds.c +++ b/src/sds.c @@ -682,6 +682,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) { switch(*f) { case '%': next = *(f+1); + if (next == '\0') break; f++; switch(next) { case 's':