From 421ff99f5d33c4be72f56f09d82f6ba6fe1bea5c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Oct 2004 13:29:20 +0000 Subject: r2788: prevent a memory leak in the pvfs search backend (This used to be commit 1de22070610231e60d329f56997bbec2cc674a4e) --- source4/ntvfs/posix/pvfs_search.c | 4 ++-- source4/ntvfs/posix/pvfs_shortname.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/posix') diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index f8d538bab2..211cb68b86 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -125,7 +125,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->both_directory_info.alloc_size = name->dos.alloc_size; file->both_directory_info.attrib = name->dos.attrib; file->both_directory_info.ea_size = name->dos.ea_size; - file->both_directory_info.short_name.s = pvfs_short_name(pvfs, name); + file->both_directory_info.short_name.s = pvfs_short_name(pvfs, file, name); file->both_directory_info.name.s = fname; return NT_STATUS_OK; @@ -154,7 +154,7 @@ static NTSTATUS fill_search_info(struct pvfs_state *pvfs, file->id_both_directory_info.attrib = name->dos.attrib; file->id_both_directory_info.ea_size = name->dos.ea_size; file->id_both_directory_info.file_id = name->dos.file_id; - file->id_both_directory_info.short_name.s = pvfs_short_name(pvfs, name); + file->id_both_directory_info.short_name.s = pvfs_short_name(pvfs, file, name); file->id_both_directory_info.name.s = fname; return NT_STATUS_OK; diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c index 33e601e429..21c0ca6ea0 100644 --- a/source4/ntvfs/posix/pvfs_shortname.c +++ b/source4/ntvfs/posix/pvfs_shortname.c @@ -38,8 +38,10 @@ char *pvfs_short_name_component(struct pvfs_state *pvfs, const char *name) return the short name for a given entry in a directory TODO: this is obviously not very useful in its current form ! */ -char *pvfs_short_name(struct pvfs_state *pvfs, struct pvfs_filename *name) +char *pvfs_short_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx, struct pvfs_filename *name) { char *p = strrchr(name->full_name, '/'); - return pvfs_short_name_component(pvfs, p+1); + char *ret = pvfs_short_name_component(pvfs, p+1); + talloc_steal(mem_ctx, ret); + return ret; } -- cgit