We need to duplicate the string as lp_load() will free the s4_conf_file
pointer and set it again.
Found with AddressSanitizer.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
/* init s4 configuration */
s4_conf_file = lpcfg_configfile(base_ctx.lp_ctx);
- if (s4_conf_file) {
- lpcfg_load(base_ctx.lp_ctx, s4_conf_file);
+ if (s4_conf_file != NULL) {
+ char *p = talloc_strdup(ctx, s4_conf_file);
+ if (p == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+ lpcfg_load(base_ctx.lp_ctx, p);
+ TALLOC_FREE(p);
} else {
lpcfg_load_default(base_ctx.lp_ctx);
}