summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-08-27 01:16:25 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:31 -0500
commit69e87ef8c3005c1cdf23e0ac46beb718986d7daa (patch)
treeb2685a687b2947016795f8b706032e716b317d20 /source3
parent5ef08833b8aea6fffe19173349c0ac9b50994b5f (diff)
downloadsamba-69e87ef8c3005c1cdf23e0ac46beb718986d7daa.tar.gz
samba-69e87ef8c3005c1cdf23e0ac46beb718986d7daa.tar.bz2
samba-69e87ef8c3005c1cdf23e0ac46beb718986d7daa.zip
r2083: Fix memleak on return code path.
Jeremy. (This used to be commit b0af241fd1fc58c1cbaadcbf6832b608923382ff)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/open.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index b08ca0f58b..6d559ac828 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -592,7 +592,7 @@ static int open_mode_check(connection_struct *conn, const char *fname, SMB_DEV_T
int i;
int num_share_modes;
int oplock_contention_count = 0;
- share_mode_entry *old_shares = 0;
+ share_mode_entry *old_shares = NULL;
BOOL fcbopen = False;
BOOL broke_oplock;
@@ -601,12 +601,15 @@ static int open_mode_check(connection_struct *conn, const char *fname, SMB_DEV_T
num_share_modes = get_share_modes(conn, dev, inode, &old_shares);
- if(num_share_modes == 0)
+ if(num_share_modes == 0) {
+ SAFE_FREE(old_shares);
return 0;
+ }
if (desired_access && ((desired_access & ~(SYNCHRONIZE_ACCESS|FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES))==0) &&
((desired_access & (SYNCHRONIZE_ACCESS|FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES)) != 0)) {
/* Stat open that doesn't trigger oplock breaks or share mode checks... ! JRA. */
+ SAFE_FREE(old_shares);
return num_share_modes;
}
@@ -758,9 +761,6 @@ after break ! For file %s, dev = %x, inode = %.0f. Deleting it to continue...\n"
free_broken_entry_list(broken_entry_list);
} while(broke_oplock);
- if(old_shares != 0)
- SAFE_FREE(old_shares);
-
/*
* Refuse to grant an oplock in case the contention limit is
* reached when going through the lock list multiple times.
@@ -772,6 +772,7 @@ after break ! For file %s, dev = %x, inode = %.0f. Deleting it to continue...\n"
oplock_contention_count ));
}
+ SAFE_FREE(old_shares);
return num_share_modes;
}