Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fix for issue #95 - Crash in XMPPvCardTemp initWithCoder

  • Loading branch information...
commit 98f9c105e0a3fdd97ac57b327e03e238d48920f4 1 parent 3181759
@robbiehanson authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 Extensions/XEP-0054/XMPPvCardTempBase.m
View
17 Extensions/XEP-0054/XMPPvCardTempBase.m
@@ -46,10 +46,19 @@ - (id)initWithCoder:(NSCoder *)coder
xmlString = [coder decodeObject];
}
- NSXMLElement *elem = [self initWithXMLString:xmlString error:nil];
- object_setClass(elem, [self class]);
-
- return elem;
+ // The method [super initWithXMLString:error:] may return a different self.
+ // In other words, it may [self release], and alloc/init/return a new self.
+ //
+ // So to maintain the proper class (XMPPvCardTempEmail, XMPPvCardTempTel, etc)
+ // we need to get a reference to the class before invoking super.
+
+ Class selfClass = [self class];
+
+ if ((self = [super initWithXMLString:xmlString error:nil]))
+ {
+ object_setClass(self, selfClass);
+ }
+ return self;
}
Please sign in to comment.
Something went wrong with that request. Please try again.