Skip to content

Commit 4f05186

Browse files
committed
[PrintAsObjC] Don't use take an ArrayRef into temporary storage.
ObjCSelector::getSelectorPieces() can return a pointer to *this, so don't use it on a temporary. Fixes an ASan-detected stack-use-after-scope, rdar://problem/31837593.
1 parent ed0bae7 commit 4f05186

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
558558
auto paramLists = AFD->getParameterLists();
559559
assert(paramLists.size() == 2 && "not an ObjC-compatible method");
560560

561-
ArrayRef<Identifier> selectorPieces
562-
= AFD->getObjCSelector().getSelectorPieces();
561+
auto selector = AFD->getObjCSelector();
562+
ArrayRef<Identifier> selectorPieces = selector.getSelectorPieces();
563563

564564
const auto &params = paramLists[1]->getArray();
565565
unsigned paramIndex = 0;

0 commit comments

Comments
 (0)