From 1f98e7b726402706f475867748c87d4213c99a25 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Thu, 24 Mar 2011 18:57:07 +0100 Subject: [PATCH] Handle nil as argument to XMPPStanza's setters --- src/XMPPStanza.m | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/XMPPStanza.m b/src/XMPPStanza.m index 34243e1..913120c 100644 --- a/src/XMPPStanza.m +++ b/src/XMPPStanza.m @@ -161,8 +161,10 @@ [old release]; [self removeAttributeForName: @"from"]; - [self addAttributeWithName: @"from" - stringValue: from_.fullJID]; + + if (from_ != nil) + [self addAttributeWithName: @"from" + stringValue: from_.fullJID]; } - (void)setTo: (XMPPJID*)to_ @@ -172,8 +174,10 @@ [old release]; [self removeAttributeForName: @"to"]; - [self addAttributeWithName: @"to" - stringValue: to_.fullJID]; + + if (to_ != nil) + [self addAttributeWithName: @"to" + stringValue: to_.fullJID]; } - (void)setType: (OFString*)type_ @@ -183,8 +187,10 @@ [old release]; [self removeAttributeForName: @"type"]; - [self addAttributeWithName: @"type" - stringValue: type]; + + if (type_ != nil) + [self addAttributeWithName: @"type" + stringValue: type]; } - (void)setID: (OFString*)ID_ @@ -194,7 +200,9 @@ [old release]; [self removeAttributeForName: @"id"]; - [self addAttributeWithName: @"id" - stringValue: ID]; + + if (ID_ != nil) + [self addAttributeWithName: @"id" + stringValue: ID]; } @end