s3:libads: Allocate ads->config.config_path under ADS_STRUCT talloc context
authorSamuel Cabrero <scabrero@samba.org>
Wed, 15 Jun 2022 10:29:15 +0000 (12:29 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 27 Jun 2022 15:50:30 +0000 (15:50 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libads/ads_struct.c
source3/libads/disp_sec.c

index 56883e8496b2ab3972416fd205ab11ee5028d173..ce07f2a89dd67ecf300f7282da1a1449da5f99b6 100644 (file)
@@ -153,7 +153,6 @@ static void ads_destroy(ADS_STRUCT **ads)
 #ifdef HAVE_LDAP
                ads_disconnect(*ads);
 #endif
-               SAFE_FREE((*ads)->config.config_path);
        }
 }
 
index 74311aac289fbec5d055bc981b2275a572b68f23..a193c5bb3e935a1f570acc1ff1fe239454671a64 100644 (file)
@@ -218,7 +218,10 @@ void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct security_descripto
 
        if (ads && !ads->config.config_path) {
                if (ADS_ERR_OK(ads_config_path(ads, mem_ctx, &tmp_path))) {
-                       ads->config.config_path = SMB_STRDUP(tmp_path);
+                       ads->config.config_path = talloc_strdup(ads, tmp_path);
+                       if (ads->config.config_path == NULL) {
+                               DBG_WARNING("Out of memory\n");
+                       }
                }
        }