From 1421705d9a8233a09f6bd7c25436ed48e640a368 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 9 Jul 2021 14:38:23 +0200 Subject: [PATCH] core: drop unnecessary initialization cunescape() sets output on success, so initialization is not necessary. There was no comment, but I think they may have been added because the compiler wasn't convinced that the return value is non-negative on success. It could have been confused by the int return type on escape*(), which was changed by the one of preceeding commits to ssize_t, or by the length calculation, so add an assert to help the compiler. For some reason coverity thinks the output can be leaked here (CID #1458111). I don't see how. --- src/basic/escape.c | 1 + src/core/load-fragment.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/escape.c b/src/basic/escape.c index 6095ac43b55..9e75c51dfcb 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -355,6 +355,7 @@ ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *p *t = 0; + assert(t >= ans); /* Let static analyzers know that the answer is non-negative. */ *ret = TAKE_PTR(ans); return t - *ret; } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index a3ac73f8232..6eefaaf27d7 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4513,7 +4513,7 @@ int config_parse_set_credential( return 0; } } else { - char *unescaped = NULL; + char *unescaped; ssize_t l; /* We support escape codes here, so that users can insert trailing \n if they like */ -- 2.47.3