Skip to content

Commit

Permalink
Fix NullPtr assignment crash in relation analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Jan 24, 2024
1 parent 51b3fd0 commit 0c72edd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/analyses/apron/relationAnalysis.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ struct
{st' with rel = rel''}
)
| (Mem v, NoOffset) ->
begin match ask.f (Queries.MayPointTo v) with
| ad when Queries.AD.is_top ad -> st
| ad ->
let mvals = Queries.AD.to_mval ad in
let ass' = List.map (fun mval -> assign_to_global_wrapper ask getg sideg st (ValueDomain.Addr.Mval.to_cil mval) f) mvals in
List.fold_right D.join ass' (D.bot ())
end
let ad = ask.f (Queries.MayPointTo v) in
Queries.AD.fold (fun addr acc ->
match addr with
| ValueDomain.Addr.Addr mval ->
D.join acc (assign_to_global_wrapper ask getg sideg st (ValueDomain.Addr.Mval.to_cil mval) f)
| UnknownPtr | NullPtr | StrPtr _ ->
D.join acc st (* Ignore assign *)
) ad (D.bot ())
(* Ignoring all other assigns *)
| _ ->
st
Expand Down Expand Up @@ -381,6 +382,8 @@ struct
if M.tracing then M.tracel "combine" "relation f: %a\n" CilType.Varinfo.pretty f.svar;
if M.tracing then M.tracel "combine" "relation formals: %a\n" (d_list "," CilType.Varinfo.pretty) f.sformals;
if M.tracing then M.tracel "combine" "relation args: %a\n" (d_list "," d_exp) args;
if M.tracing then M.tracel "combine" "relation st: %a\n" D.pretty st;
if M.tracing then M.tracel "combine" "relation fun_st: %a\n" D.pretty fun_st;
let new_fun_rel = RD.add_vars fun_st.rel (RD.vars st.rel) in
let arg_substitutes =
let filter_actuals (x,e) =
Expand Down

0 comments on commit 0c72edd

Please sign in to comment.