Don't assume that the (files_struct *) passed to fd_attempt_close()
authorTim Potter <tpot@samba.org>
Thu, 17 Feb 2000 23:22:26 +0000 (23:22 +0000)
committerTim Potter <tpot@samba.org>
Thu, 17 Feb 2000 23:22:26 +0000 (23:22 +0000)
will be non-NULL.
(This used to be commit 02f845e54351ec57ee873a8ed887285552c6ecab)

source3/smbd/open.c

index 30409707d30d24b5371cd04f1fe4e44326c90af7..6352233dbcf728077976d46792cd7a8d61d79b4c 100644 (file)
@@ -152,11 +152,18 @@ Decrements the ref_count and returns it.
 uint16 fd_attempt_close(files_struct *fsp, int *err_ret)
 {
   extern struct current_user current_user;
-  file_fd_struct *fd_ptr = fsp->fd_ptr;
-  uint16 ret_ref = fd_ptr->ref_count;
+  file_fd_struct *fd_ptr;
+  uint16 ret_ref;
 
   *err_ret = 0;
 
+  if ((fsp == NULL) || (fsp->fd_ptr == NULL)) {
+      return 0;
+  }
+
+  fd_ptr = fsp->fd_ptr;
+  ret_ref = fd_ptr->ref_count;
+
   DEBUG(3,("fd_attempt_close fd = %d, dev = %x, inode = %.0f, open_flags = %d, ref_count = %d.\n",
           fd_ptr->fd, (unsigned int)fd_ptr->dev, (double)fd_ptr->inode,
           fd_ptr->real_open_flags,