diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c
index 612c7e909e84e2ce9a667e165996ba98d09e39cc..94bdff84a7604117c0e9b4b759fd2119d7b9cd4d 100644
--- a/src/smblib/smblib.c
+++ b/src/smblib/smblib.c
@@ -1340,6 +1340,11 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
 		return(SMB_ERR_HDR_LEN);
 	}
 
+	if(smb->shd_fp==NULL) {
+		sprintf(smb->last_error,"msgbase not open");
+		return(SMB_ERR_NOT_OPEN);
+	}
+
 	if(!smb->locked && smb_locksmbhdr(smb))
 		return(SMB_ERR_LOCK);
 	if((i=smb_getstatus(smb))!=0) {