From: Sreeja Athirkandathil Narayanan (sathirka) Date: Tue, 18 Apr 2023 19:31:48 +0000 (+0000) Subject: Pull request #3807: appid: Making free_servicematch_list thread local X-Git-Tag: 3.1.60.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1e041964a13d97db6d57fec0ce290e86d8f70c5;p=thirdparty%2Fsnort3.git Pull request #3807: appid: Making free_servicematch_list thread local Merge in SNORT/snort3 from ~OSTEPANO/snort3:csd_pattern_search_crash to master Squashed commit of the following: commit d8dc69deffebdb3205b7a11a9e0d35a72223228c Author: Oleksandr Stepanov Date: Fri Apr 14 09:54:00 2023 -0400 appid: Making free_servicematch_list thread local --- diff --git a/src/network_inspectors/appid/detector_plugins/detector_pattern.cc b/src/network_inspectors/appid/detector_plugins/detector_pattern.cc index b371119bf..e56e7aeb5 100644 --- a/src/network_inspectors/appid/detector_plugins/detector_pattern.cc +++ b/src/network_inspectors/appid/detector_plugins/detector_pattern.cc @@ -145,7 +145,7 @@ struct PServiceMatch Pattern* data; }; -static PServiceMatch* free_servicematch_list; +static THREAD_LOCAL PServiceMatch* free_servicematch_list; static int pattern_match(void* id, void*, int match_end_pos, void* data, void*) { @@ -263,6 +263,13 @@ static int csd_pattern_tree_search(const uint8_t* data, uint16_t size, SearchToo free_servicematch_list = sm; } + while (free_servicematch_list) + { + auto tmp = free_servicematch_list; + free_servicematch_list = free_servicematch_list->next; + snort_free(tmp); + } + if (ps == nullptr) return 0;