mp: Always set mp_context to NULL on errors.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 16 Mar 2020 17:44:07 +0000 (18:44 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 17 Sep 2020 15:43:02 +0000 (17:43 +0200)
In mp_init(), if mp_yyparse() fails, we return early without setting
the result pointer to NULL. This does not matter much because both
callers of mood.c pass in NULL, but still..

mp.c

diff --git a/mp.c b/mp.c
index bade05bcf866103b5bd794af4ae1ae6ce8cb5b72..56c16e31d7baf64fbf7c415b015b3de2967b6a38 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -491,10 +491,10 @@ int mp_init(const char *definition, int nbytes, struct mp_context **result,
        struct mp_context *ctx;
        struct yy_buffer_state *buffer_state;
 
        struct mp_context *ctx;
        struct yy_buffer_state *buffer_state;
 
+       *result = NULL;
        if (!definition || nbytes == 0) { /* dummy mood */
                if (errmsg)
                        *errmsg = NULL;
        if (!definition || nbytes == 0) { /* dummy mood */
                if (errmsg)
                        *errmsg = NULL;
-               *result = NULL;
                return 0;
        }
        ctx = para_calloc(sizeof(*ctx));
                return 0;
        }
        ctx = para_calloc(sizeof(*ctx));