From 64ee8dbffb655c10c2fed74992ce8f9afbd4a8f6 Mon Sep 17 00:00:00 2001 From: haritowa Date: Tue, 20 Dec 2016 01:06:23 +0300 Subject: [PATCH] [ASDisplayNode Deallocation] Fix for crash when certain types are used as instance variables. (#2803) * Fix https://github.com/facebook/AsyncDisplayKit/issues/2802 * Change nil to NULL --- AsyncDisplayKit/ASDisplayNode.mm | 2 +- AsyncDisplayKit/Private/ASInternalHelpers.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 435e40ba92..215c4dce8f 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -542,7 +542,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) Ivar ivar = allMyIvars[i]; const char *type = ivar_getTypeEncoding(ivar); - if (strcmp(type, @encode(id)) == 0) { + if (type != NULL && strcmp(type, @encode(id)) == 0) { // If it's `id` we have to include it just in case. resultIvars[resultCount] = ivar; resultCount += 1; diff --git a/AsyncDisplayKit/Private/ASInternalHelpers.m b/AsyncDisplayKit/Private/ASInternalHelpers.m index 4a78f14d65..d57f8ba35c 100644 --- a/AsyncDisplayKit/Private/ASInternalHelpers.m +++ b/AsyncDisplayKit/Private/ASInternalHelpers.m @@ -107,7 +107,7 @@ BOOL ASClassRequiresMainThreadDeallocation(Class class) Class _Nullable ASGetClassFromType(const char *type) { // Class types all start with @" - if (strncmp(type, "@\"", 2) != 0) { + if (type == NULL || strncmp(type, "@\"", 2) != 0) { return nil; }