]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Attempt to keep coverity from being silly (CID #1551707)
authorJames Jones <jejones3141@gmail.com>
Tue, 23 Jan 2024 17:21:44 +0000 (11:21 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 Jan 2024 19:47:57 +0000 (13:47 -0600)
For some unknown reason, Coverity skips the declaration of subst in
fr_vasprintf_internal()...and said declaration initializes it, so
that later, when substr is used, Coverity complains that subst is
not initialized!

To try to avoid this; we move the declaration of subst out of the
do {} while () loop it was in, to the outer block of the function
body, and then just assign to it in the loop.

src/lib/util/print.c

index ece56f11a50d9536c2c470e9d961f40f486310ae..ae8a8f6668b6d155854898ffd05d932a6c8b564d 100644 (file)
@@ -477,6 +477,7 @@ static char *fr_vasprintf_internal(TALLOC_CTX *ctx, char const *fmt, va_list ap,
        char const      *p = fmt, *end = p + strlen(fmt), *fmt_p = p, *fmt_q = p;
        char            *out = NULL, *out_tmp;
        va_list         ap_p, ap_q;
+       char            *subst;
 
        out = talloc_strdup(ctx, "");
        va_copy(ap_p, ap);
@@ -485,7 +486,8 @@ static char *fr_vasprintf_internal(TALLOC_CTX *ctx, char const *fmt, va_list ap,
        do {
                char const      *q;
                char            len[2] = { '\0', '\0' };
-               char            *subst = NULL;
+
+               subst = NULL;
 
                if ((*p != '%') || (*++p == '%')) {
                        fmt_q = p + 1;