[pulse] Model Core Graphics Create and Copy just like malloc

Summary: Unify the models of malloc and for the Create and Copy functions for Core Graphics. This add the null case from the malloc model to the Core Graphics models.

Reviewed By: jvillard

Differential Revision: D20890956

fbshipit-source-id: 278ac9d2f
master
Dulma Churchill 5 years ago committed by Facebook GitHub Bot
parent 59ea968de8
commit 2382e3d613

@ -275,17 +275,6 @@ module StdAtomicInteger = struct
[PulseExecutionState.ContinueProgram astate]
end
module ObjectiveC = struct
let alloc _ : model =
fun ~caller_summary:_ ~callee_procname location ~ret:(ret_id, _) astate ->
let hist =
[ValueHistory.Allocation {f= Model (Procname.to_string callee_procname); location}]
in
let ret_addr = AbstractValue.mk_fresh () in
let astate = PulseOperations.allocate callee_procname location (ret_addr, hist) astate in
PulseOperations.write_id ret_id (ret_addr, hist) astate |> PulseOperations.ok_continue
end
module JavaObject = struct
(* naively modeled as shallow copy. *)
let clone src_pointer_hist : model =
@ -562,7 +551,7 @@ module ProcNameDispatcher = struct
&:: "nextElement" <>$ capt_arg_payload
$!--> fun x -> StdVector.at ~desc:"Enumeration.nextElement" x (AbstractValue.mk_fresh (), [])
)
; +PatternMatch.ObjectiveC.is_core_graphics_create_or_copy &++> ObjectiveC.alloc
; +PatternMatch.ObjectiveC.is_core_graphics_create_or_copy &++> C.malloc
; +PatternMatch.ObjectiveC.is_core_graphics_release <>$ capt_arg_payload $--> C.free
; -"CFRelease" <>$ capt_arg_payload $--> C.free
; -"CFAutorelease" <>$ capt_arg_payload $--> C.free ]

@ -37,8 +37,10 @@
+ (void)cg_path_create_mutable_no_leak_good:(CGRect)rect {
CGFloat lineThickness = 0.20f * CGRectGetHeight(rect);
// One rectangle
CGMutablePathRef path1 = CGPathCreateMutable();
CFRelease(path1);
CGMutablePathRef path = CGPathCreateMutable();
if (!path)
return;
CFRelease(path);
}
+ (void)cg_bitmap_context_create_image_no_leak_good {

Loading…
Cancel
Save