From 7f5e8ff50d8af0598bfb61ae518abbce90fe63fa Mon Sep 17 00:00:00 2001 From: "Sumit Kumar (sumikum7)" Date: Wed, 26 Mar 2025 09:35:39 +0000 Subject: [PATCH] Pull request #4651: file_api: making current_context as nullptr before it gets the value of ctx Merge in SNORT/snort3 from ~SUMIKUM7/snort3:coverity_CSCwo20068_snort to master Squashed commit of the following: commit 4004df617faf5598c181ae672b1b304e3e440c1b Author: Sumit Kumar Date: Wed Mar 5 15:31:53 2025 +0530 file_api: making current_context as nullptr before it gets the value of ctx file_api: since current_context would never be file_got hence removing this style check file_api: making current_context as nullptr before it gets the value of ctx and removing redundant part of if check --- src/file_api/file_flows.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/file_api/file_flows.cc b/src/file_api/file_flows.cc index 51a33aec1..de855e5bb 100644 --- a/src/file_api/file_flows.cc +++ b/src/file_api/file_flows.cc @@ -173,11 +173,12 @@ void FileFlows::set_current_file_context(FileContext* ctx) { int64_t file_id = current_context->get_file_id(); delete current_context; + current_context = nullptr; current_context_delete_pending = false; FileCache* file_cache = FileService::get_file_cache(); assert(file_cache); FileContext* file_got = file_cache->get_file(flow, file_id, false, false); - if (file_got and file_got->verdict == FILE_VERDICT_PENDING and current_context != file_got) + if (file_got and file_got->verdict == FILE_VERDICT_PENDING) { file_got->user_file_data_mutex.lock(); delete(file_got->get_file_data()); -- 2.47.2