Bug 1692391 - Remove NS_OBJC_TRY_EXPR_ABORT macro and replace its use with the block version of the macro. r=haik

This macro was quite misguided, too. If evaluating _e raised an exception, then
the expression value of the block would be an uninitialized value. Super unsafe.
It's a good thing that we don't expect "retain" to ever throw.

Differential Revision: https://phabricator.services.mozilla.com/D104954
This commit is contained in:
Markus Stange 2021-02-16 22:55:19 +00:00
Родитель 173c610fda
Коммит fd5389943b
2 изменённых файлов: 3 добавлений и 12 удалений

Просмотреть файл

@ -50,7 +50,9 @@ using mozilla::StaticMutex;
class nsAutoRetainCocoaObject {
public:
explicit nsAutoRetainCocoaObject(id anObject) {
mObject = NS_OBJC_TRY_EXPR_ABORT([anObject retain]);
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mObject = [anObject retain];
NS_OBJC_END_TRY_ABORT_BLOCK;
}
~nsAutoRetainCocoaObject() {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

Просмотреть файл

@ -21,17 +21,6 @@
void nsObjCExceptionLog(NSException* aException);
#define NS_OBJC_TRY_EXPR_ABORT(_e) \
({ \
typeof(_e) _tmp; \
@try { \
_tmp = (_e); \
} @catch (NSException * _exn) { \
nsObjCExceptionLog(_exn); \
} \
_tmp; \
})
// For wrapping blocks of Obj-C calls. Does not actually terminate.
#define NS_OBJC_BEGIN_TRY_ABORT_BLOCK @try {
#define NS_OBJC_END_TRY_ABORT_BLOCK \