lib:param: Fix memory leak in lpcfg_load_internal()
authorawalker <awalker@ixsystems.com>
Mon, 6 Apr 2020 19:50:41 +0000 (15:50 -0400)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 13 May 2020 17:34:43 +0000 (17:34 +0000)
Signed-off-by: awalker <awalker@ixsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed May 13 17:34:43 UTC 2020 on sn-devel-184

lib/param/loadparm.c

index 777999a3a76e65174e692a28c867f8d11280f825..d00ed9dca439a1b96b8c4538060977a2fba86492 100644 (file)
@@ -3229,9 +3229,12 @@ static bool lpcfg_load_internal(struct loadparm_context *lp_ctx,
        char *n2;
        bool bRetval;
 
-       filename = talloc_strdup(lp_ctx, filename);
+       if (lp_ctx->szConfigFile != NULL) {
+               talloc_free(discard_const_p(char, lp_ctx->szConfigFile));
+               lp_ctx->szConfigFile = NULL;
+       }
 
-       lp_ctx->szConfigFile = filename;
+       lp_ctx->szConfigFile = talloc_strdup(lp_ctx, filename);
 
        if (lp_ctx->s3_fns) {
                return lp_ctx->s3_fns->load(filename);