Skip to content

Commit

Permalink
Fix the mem leak check function
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstanb committed Aug 8, 2023
1 parent 3bf7d4a commit 908aa59
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/analyses/memLeak.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ struct
let check_for_mem_leak ?(assert_exp_imprecise = false) ?(exp = None) ctx =
let state = ctx.local in
if not @@ D.is_empty state then
if assert_exp_imprecise && Option.is_some exp then
M.warn ~category:(Behavior (Undefined MemoryLeak)) ~tags:[CWE 401] "assert expression %a is unknown. Memory leak might possibly occur for heap variables: %a" d_exp (Option.get exp) D.pretty state
else
M.warn ~category:(Behavior (Undefined MemoryLeak)) ~tags:[CWE 401] "Memory leak detected for heap variables: %a" D.pretty state
match assert_exp_imprecise, exp with
| true, Some exp -> M.warn ~category:(Behavior (Undefined MemoryLeak)) ~tags:[CWE 401] "assert expression %a is unknown. Memory leak might possibly occur for heap variables: %a" d_exp exp D.pretty state
| _ -> M.warn ~category:(Behavior (Undefined MemoryLeak)) ~tags:[CWE 401] "Memory leak detected for heap variables: %a" D.pretty state

(* TRANSFER FUNCTIONS *)
let assign ctx (lval:lval) (rval:exp) : D.t =
Expand Down

0 comments on commit 908aa59

Please sign in to comment.