Skip to content

Commit e166816

Browse files
authored
[WebKit Checkers] Treat a boxed value as a safe pointer origin (#161133)
1 parent 631719d commit e166816

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ bool tryToFindPtrOrigin(
208208
continue;
209209
}
210210
if (auto *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
211+
if (StopAtFirstRefCountedObj)
212+
return callback(BoxedExpr, true);
211213
E = BoxedExpr->getSubExpr();
212214
continue;
213215
}

clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,18 @@ void foo() {
398398
void baz(const NSDictionary *);
399399
void boo(NSNumber *);
400400
void boo(CFTypeRef);
401-
void foo() {
401+
402+
struct Details {
403+
int value;
404+
};
405+
406+
void foo(Details* details) {
402407
CFArrayCreateMutable(kCFAllocatorDefault, 10);
403408
bar(@[@"hello"]);
404409
baz(@{@"hello": @3});
405410
boo(@YES);
406411
boo(@NO);
412+
boo(@(details->value));
407413
}
408414
}
409415

0 commit comments

Comments
 (0)