Ensure on error or clean return we don't leave memory on mem_ctx.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14282
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit
74b47bf578dab9ce94a9f2439fa672e51afe809e)
prot = strtok_r(temp, ":", &saveptr);
if (!prot) {
DEBUG(0,("parse_msdfs_symlink: invalid path !\n"));
+ TALLOC_FREE(temp);
return false;
}
alt_path = talloc_array(ctx, char *, MAX_REFERRAL_COUNT);
if (!alt_path) {
+ TALLOC_FREE(temp);
return false;
}
reflist = talloc_zero_array(ctx,
struct referral, count);
if(reflist == NULL) {
+ TALLOC_FREE(temp);
TALLOC_FREE(alt_path);
return false;
}
p++;
}
- reflist[i].alternate_path = talloc_asprintf(ctx,
+ reflist[i].alternate_path = talloc_asprintf(reflist,
"\\%s",
p);
if (!reflist[i].alternate_path) {
+ TALLOC_FREE(temp);
+ TALLOC_FREE(alt_path);
+ TALLOC_FREE(reflist);
return false;
}
if (ppreflist != NULL) {
*ppreflist = reflist;
+ } else {
+ TALLOC_FREE(reflist);
}
if (prefcount != NULL) {
*prefcount = count;
}
+ TALLOC_FREE(temp);
TALLOC_FREE(alt_path);
return true;
}