]> jfr.im git - irc/atheme/libmowgli-2.git/commitdiff
src/libmowgli/base/argstack.c: remove erroneous invocation of va_end(3)
authorAaron Jones <redacted>
Mon, 26 Feb 2018 04:06:58 +0000 (04:06 +0000)
committerAaron Jones <redacted>
Mon, 26 Feb 2018 04:06:58 +0000 (04:06 +0000)
The stdarg(3) manpage states:

va_end()
    Each invocation of va_start() must be matched by a cor‐
    responding invocation of va_end() in the *same function*.
    After the call va_end(ap) the variable ap is *undefined*.
    Multiple  traversals  of  the  list,  each bracketed by
    va_start() and va_end() are possible.  va_end() may  be
    a macro or a function.

(Emphasis mine)

However, va_start(3) was not called in this function, and
callers of mowgli_argstack_create_from_va_list() also call
va_end(3) after it returns. This means both that the varargs
will always be cleaned up, and if the function ran into an
error, it would erroneously clean it up and then the caller
would be invoking va_end(3) on an uninitialized list.

This was found by the Clang static analyzer while performing
an analysis on Atheme IRC Services.

src/libmowgli/base/argstack.c

index 94902afce3a5d630f21d2f23e4bfb69862616b61..28ef45df9febd9ae88ff4b87bab5897758efc73c 100644 (file)
@@ -104,7 +104,6 @@ mowgli_argstack_create_from_va_list(const char *descstr, va_list va)
                        e->type = MOWGLI_ARG_BOOLEAN;
                        break;
                default:
-                       va_end(va);
                        mowgli_object_unref(out);
                        mowgli_log_warning("invalid description");
                        return NULL;