[infer][nullable checker] no report for objects created by URLWithString:

Reviewed By: sblackshear

Differential Revision: D6354108

fbshipit-source-id: 16e3fe0
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent a4428a4cae
commit 354b46f8ca

@ -29,6 +29,12 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
(Specs.proc_resolve_attributes callee_pname)
let is_blacklisted callee_pname =
let blacklist = ["URLWithString:"]
and simplified_callee_pname = Typ.Procname.to_simplified_string callee_pname in
List.exists ~f:(String.equal simplified_callee_pname) blacklist
let report_nullable_dereference ap call_sites {ProcData.pdesc; extras} loc =
let pname = Procdesc.get_proc_name pdesc in
let annotation = Localise.nullable_annotation_name pname in
@ -162,6 +168,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| Call (_, Direct callee_pname, (HilExp.AccessPath receiver) :: _, _, _)
when Models.is_check_not_null callee_pname ->
assume_pnames_notnull receiver astate
| Call (_, Direct callee_pname, _, _, _) when is_blacklisted callee_pname ->
astate
| Call (Some ret_var, Direct callee_pname, _, _, loc)
when Annotations.pname_has_return_annot callee_pname
~attrs_of_pname:Specs.proc_resolve_attributes Annotations.ia_is_nullable ->

@ -140,4 +140,9 @@ int* __nullable returnsNull();
return array;
}
- (NSArray*)URLWithStringOkay {
NSURL* url = [NSURL URLWithString:@"some/url/string"];
NSArray* array = @[ url ];
}
@end

@ -1,5 +1,7 @@
codetoanalyze/objc/checkers/Nullable.m, T_FP_dereferenceNonnullFieldAfterTestForNullOkay, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here]
codetoanalyze/objc/checkers/Nullable.m, T_FP_dereferenceNonnullFieldAfterTestForNullOkay, 2, NULL_DEREFERENCE, [start of procedure FP_dereferenceNonnullFieldAfterTestForNullOkay,Condition is true]
codetoanalyze/objc/checkers/Nullable.m, T_URLWithStringOkay, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/objc/checkers/Nullable.m, T_URLWithStringOkay, 2, NULL_DEREFERENCE, [start of procedure URLWithStringOkay,Skipping URLWithString:: function or method not found]
codetoanalyze/objc/checkers/Nullable.m, T_assignNonnullFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is assigned null here]
codetoanalyze/objc/checkers/Nullable.m, T_assignUnnanotatedFieldToNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is assigned null here]
codetoanalyze/objc/checkers/Nullable.m, T_dereferenceNullableFieldBad, 1, NULL_DEREFERENCE, [start of procedure dereferenceNullableFieldBad]

Loading…
Cancel
Save