From d5edf302c9ca1a48927c8a6db780b8e193edfd05 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 10 Jun 2020 15:21:35 +0200 Subject: [PATCH] smbd: maintain correct destructor order in fsp_free() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/files.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 350a2bf85e0..fb3934867b1 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -919,6 +919,18 @@ void fsp_free(files_struct *fsp) fsp->conn->num_files_open--; + if (fsp->fsp_name != NULL && + fsp->fsp_name->fsp_link != NULL) + { + /* + * Free fsp_link of fsp->fsp_name. To do this in the correct + * talloc destructor order we have to do it here. The + * talloc_free() of the link should set the fsp pointer to NULL. + */ + TALLOC_FREE(fsp->fsp_name->fsp_link); + SMB_ASSERT(fsp->fsp_name->fsp == NULL); + } + /* this is paranoia, just in case someone tries to reuse the information */ ZERO_STRUCTP(fsp); -- 2.47.3