summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-23 02:52:36 +0000
committerJeremy Allison <jra@samba.org>2002-11-23 02:52:36 +0000
commitde474974ea25df7738dd175126e3f1de0df47ea6 (patch)
treeb9d41afb7e5c64a91fb5538c05e9d3358909c386 /source3/locking
parent46d5c060c60753b94ae97ccd48aa7a8be791feed (diff)
downloadsamba-de474974ea25df7738dd175126e3f1de0df47ea6.tar.gz
samba-de474974ea25df7738dd175126e3f1de0df47ea6.tar.bz2
samba-de474974ea25df7738dd175126e3f1de0df47ea6.zip
Lots of fixes for error paths where tdb_fetch() data need freeing.
Found via a post from Arcady Chernyak <Arcady.Chernyak@efi.com>. Jeremy. (This used to be commit 5d5762d1787db4392d2dff16024097c638b2d494)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c4
-rw-r--r--source3/locking/posix.c25
2 files changed, 17 insertions, 12 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 3eb7ca4783..e8b6f3428f 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -652,8 +652,10 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
size = dbuf.dsize + sizeof(share_mode_entry);
p = malloc(size);
- if (!p)
+ if (!p) {
+ SAFE_FREE(dbuf.dptr);
return False;
+ }
memcpy(p, dbuf.dptr, sizeof(*data));
fill_share_mode(p + sizeof(*data), fsp, port, op_type);
memcpy(p + sizeof(*data) + sizeof(share_mode_entry), dbuf.dptr + sizeof(*data),
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index f7a8cd3d39..94055de2b0 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -149,7 +149,7 @@ static size_t get_posix_pending_close_entries(files_struct *fsp, int **entries)
dbuf = tdb_fetch(posix_pending_close_tdb, kbuf);
- if (!dbuf.dptr) {
+ if (!dbuf.dptr) {
return 0;
}
@@ -176,7 +176,7 @@ static size_t get_posix_lock_entries(files_struct *fsp, struct posix_lock **entr
dbuf = tdb_fetch(posix_lock_tdb, kbuf);
- if (!dbuf.dptr) {
+ if (!dbuf.dptr) {
return 0;
}
@@ -338,8 +338,9 @@ static BOOL delete_posix_lock_entry_by_index(files_struct *fsp, size_t entry)
return True;
fail:
- SAFE_FREE(dbuf.dptr);
- return False;
+
+ SAFE_FREE(dbuf.dptr);
+ return False;
}
/****************************************************************************
@@ -385,17 +386,18 @@ static BOOL add_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T s
goto fail;
}
- SAFE_FREE(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
DEBUG(10,("add_posix_lock: File %s: type = %s: start=%.0f size=%.0f: dev=%.0f inode=%.0f\n",
fsp->fsp_name, posix_lock_type_name(lock_type), (double)start, (double)size,
(double)fsp->dev, (double)fsp->inode ));
- return True;
+ return True;
fail:
- SAFE_FREE(dbuf.dptr);
- return False;
+
+ SAFE_FREE(dbuf.dptr);
+ return False;
}
/****************************************************************************
@@ -492,13 +494,14 @@ static int delete_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T
posix_lock_type_name(pl->lock_type), (double)pl->start, (double)pl->size,
(unsigned int)num_overlapping_records ));
- SAFE_FREE(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return num_overlapping_records;
fail:
- SAFE_FREE(dbuf.dptr);
- return -1;
+
+ SAFE_FREE(dbuf.dptr);
+ return -1;
}
/****************************************************************************