CWE-910
Use of Expired File Descriptor. [Resource-Management-Errors, Improper-Control-Of-A-Resource-Through-Its-Lifetime]
Required inputs: IR, StaticSemanticAnalysis
The product uses or accesses a file descriptor after it has been closed. After a file descriptor for a particular file or device has been released, it can be reused. The code might not write to the original file, since the reused file descriptor might reference a different file or device.Excerpts from CWE [https://cwe.mitre.org], Copyright (C) 2006-2026, the MITRE Corporation. See section 9.4. "3rd-Party Licenses" in the documentation for full details.Possible Messages
Key |
Text |
Severity |
Disabled |
possible_use_after_free |
File descriptor possibly used after it was previously released |
None |
False |
use_after_free |
File descriptor used after it was previously released |
None |
False |
Options
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
functions_with_ignored_deallocators
functions_with_ignored_deallocators : set[str] = set()
Set of functions (given by their qualified name) where all deallocators are
ignored. For these functions, the check will never report a use-after-free. It will
also assume that these functions never create freed pointers, neither by return
value, out param, nor by modifying global state.
report_freed_this_at_call
report_freed_this_at_call : bool = False
This option controls findings when a freed pointer is used in C++ to call a
non-static member function. When set to true, the use at the call is directly
reported. When false, the analysis waits for an actual dereference (of the
this-pointer then) inside the callee, and only reports those.
report_read_pointer_args_in_calls_to_undefined
report_read_pointer_args_in_calls_to_undefined : bool = True
Report when freed pointers are passed to undefined (external) functions.
resources
resources : set[str] = {'FileHandle'}
Set of resources to be checked (selection of rules in the Resources group).
witness_paths
witness_paths : bool = True
Whether witness paths should be determined and included in the issue.