diff --git a/infer/src/IR/HilInstr.ml b/infer/src/IR/HilInstr.ml index c4a33cfb6..21c101dc7 100644 --- a/infer/src/IR/HilInstr.ml +++ b/infer/src/IR/HilInstr.ml @@ -94,7 +94,7 @@ let of_sil ~include_array_indexes ~f_resolve_id (instr: Sil.instr) = -> let hil_ret = Option.map ~f:(fun (ret_id, ret_typ) -> (Var.of_id ret_id, ret_typ)) ret_opt in let hil_call = match exp_of_sil call_exp (Typ.mk Tvoid) with - | Constant Cfun procname + | Constant Cfun procname | Closure (procname, _) -> Direct procname | AccessPath access_path -> Indirect access_path diff --git a/infer/tests/codetoanalyze/objc/checkers/Nullable.m b/infer/tests/codetoanalyze/objc/checkers/Nullable.m index 81b6f3d75..7c7a0da3e 100644 --- a/infer/tests/codetoanalyze/objc/checkers/Nullable.m +++ b/infer/tests/codetoanalyze/objc/checkers/Nullable.m @@ -40,6 +40,18 @@ } } +- (int)testUnnanotatedFieldInClosureBad { + int (^testField)(int defaultValue); + testField = ^(int defaultValue) { + if (unnanotatedField != nil) { + return *unnanotatedField; + } else { + return defaultValue; + } + }; + return testField(42); +} + - (void)testNonnullFieldForNullBad { if (nonnullField == nil) { } diff --git a/infer/tests/codetoanalyze/objc/checkers/issues.exp b/infer/tests/codetoanalyze/objc/checkers/issues.exp index a3edd6264..cab882921 100644 --- a/infer/tests/codetoanalyze/objc/checkers/issues.exp +++ b/infer/tests/codetoanalyze/objc/checkers/issues.exp @@ -7,3 +7,4 @@ codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestFo codetoanalyze/objc/checkers/Nullable.m, T_dereferenceUnnanotatedFieldAfterTestForNullBad, 2, NULL_DEREFERENCE, [start of procedure dereferenceUnnanotatedFieldAfterTestForNullBad,Condition is true] codetoanalyze/objc/checkers/Nullable.m, T_testNonnullFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field nonnullField is compared to null here] codetoanalyze/objc/checkers/Nullable.m, T_testUnnanotatedFieldForNullBad, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here] +codetoanalyze/objc/checkers/Nullable.m, __objc_anonymous_block_T_testUnnanotatedFieldInClosureBad______1, 1, FIELD_SHOULD_BE_NULLABLE, [Field unnanotatedField is compared to null here]