From 53e6aec80d186795fe41a1c48ee0e9489c8ea490 Mon Sep 17 00:00:00 2001 From: Xiaoyu Liu Date: Fri, 21 May 2021 02:03:10 -0700 Subject: [PATCH] Fix .NET resource leak detection leaked type lost (#1446) Summary: Hi all, This is just a small fix tries to resolve the leaked type lost issue. It was excluded from previous CIL race condition PR due to irrelevance. Thanks! Pull Request resolved: https://github.com/facebook/infer/pull/1446 Reviewed By: skcho Differential Revision: D28566755 Pulled By: ngorogiannis fbshipit-source-id: 1c9938d9c --- infer/src/dotnet/ResourceLeakCSDomain.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infer/src/dotnet/ResourceLeakCSDomain.ml b/infer/src/dotnet/ResourceLeakCSDomain.ml index 5c41df7c6..e9d7dc4ac 100644 --- a/infer/src/dotnet/ResourceLeakCSDomain.ml +++ b/infer/src/dotnet/ResourceLeakCSDomain.ml @@ -97,7 +97,9 @@ let release_resource access_path held = let old_count = find_count access_path held in let remove_resource_from_hash = match old_count with - | NonTop count when count < 2 -> + | Top -> + Hashtbl.remove !type_map access_path + | NonTop count when count <= 0 -> Hashtbl.remove !type_map access_path | _ -> ()