summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-01-09 11:22:29 +0100
committerMichael Adam <obnox@samba.org>2008-01-09 11:25:43 +0100
commit79180e65639e1ddf8aa0f55688de98a51c8dcbfa (patch)
tree0bb58ea52d891337dbc40a21ab9115dc83634aa0 /source3/torture
parent059be4dda06b51d04ed33c752d688ce46018fbdd (diff)
downloadsamba-79180e65639e1ddf8aa0f55688de98a51c8dcbfa.tar.gz
samba-79180e65639e1ddf8aa0f55688de98a51c8dcbfa.tar.bz2
samba-79180e65639e1ddf8aa0f55688de98a51c8dcbfa.zip
Fix memory handling in torture/cmd_vfs.c:cmd_open and don't leak fsp_name.
Michael (This used to be commit f93fc818143a7442a6e8a90f16f60c536a5b8f9e)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/cmd_vfs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index fbf9c3c9e3..e349df6061 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -279,14 +279,27 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
}
fsp = SMB_MALLOC_P(struct files_struct);
+ if (fsp == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
fsp->fsp_name = SMB_STRDUP(argv[1]);
+ if (fsp->fsp_name == NULL) {
+ SAFE_FREE(fsp);
+ return NT_STATUS_NO_MEMORY;
+ }
fsp->fh = SMB_MALLOC_P(struct fd_handle);
+ if (fsp->fh == NULL) {
+ SAFE_FREE(fsp->fsp_name);
+ SAFE_FREE(fsp);
+ return NT_STATUS_NO_MEMORY;
+ }
fsp->conn = vfs->conn;
fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, argv[1], fsp, flags, mode);
if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
SAFE_FREE(fsp->fh);
+ SAFE_FREE(fsp->fsp_name);
SAFE_FREE(fsp);
return NT_STATUS_UNSUCCESSFUL;
}