MCPcopy Create free account
hub / github.com/CodeSentryAI/lockbud / detect

Method detect

src/detector/memory/invalid_free.rs:40–68  ·  view source on GitHub ↗
(
        &self,
        callgraph: &CallGraph<'tcx>,
        alias_analysis: &mut AliasAnalysis,
    )

Source from the content-addressed store, hash-verified

38 }
39
40 pub fn detect(
41 &self,
42 callgraph: &CallGraph<'tcx>,
43 alias_analysis: &mut AliasAnalysis,
44 ) -> Vec<Report> {
45 let uninits = self.collect_uninit(callgraph);
46 let caller_callsites = self.collect_caller_callsites(uninits, callgraph);
47 let manual_drops = collect_manual_drop(callgraph, self.tcx);
48 let mut reports = Vec::new();
49 for (caller_id, callsites) in caller_callsites {
50 let manual_drops = match manual_drops.get(&caller_id) {
51 Some(v) => v.clone(),
52 None => Vec::new(),
53 };
54 if let Some(diagnosis) = self.detect_caller_callsites(
55 caller_id,
56 &callsites,
57 callgraph,
58 alias_analysis,
59 &manual_drops,
60 ) {
61 for d in diagnosis {
62 let content = ReportContent::new("InvalidFree".to_owned(), "Possibly".to_owned(), d, "Call mem::uninitialized() or MaybeUninit::uninit() followed by assume_init() without actually write on not simple types".to_owned());
63 reports.push(Report::InvalidFree(content));
64 }
65 }
66 }
67 reports
68 }
69
70 /// Collect Uninit APIs.
71 fn collect_uninit(&self, callgraph: &CallGraph<'tcx>) -> FxHashMap<InstanceId, UninitApi> {

Callers

nothing calls this directly

Calls 4

collect_manual_dropFunction · 0.85
collect_uninitMethod · 0.80

Tested by

no test coverage detected