[Adium-commits] adium 2017:ffda06c9025e: Protect against get_cb_real_name return...
adium-commits at adiumx.com
adium-commits at adiumx.com
Tue Apr 28 14:44:24 UTC 2009
details: http://hg.adiumx.com/adium/rev/ffda06c9025e
revision: 2017:ffda06c9025e
author: Zachary West <zacw at adiumx.com>
date: Tue Apr 28 10:44:15 2009 -0400
Protect against get_cb_real_name returning NULL, since apparently the jabber prpl likes to do so. Fixes #11963.
diffstat:
Plugins/Purple Service/adiumPurpleConversation.m | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diffs (42 lines):
diff -r 460e4914297f -r ffda06c9025e Plugins/Purple Service/adiumPurpleConversation.m
--- a/Plugins/Purple Service/adiumPurpleConversation.m Tue Apr 28 02:54:34 2009 -0700
+++ b/Plugins/Purple Service/adiumPurpleConversation.m Tue Apr 28 10:44:15 2009 -0400
@@ -276,23 +276,27 @@
PurplePluginProtocolInfo *prpl_info = (prpl ? PURPLE_PLUGIN_PROTOCOL_INFO(prpl) : NULL);
PurpleConvChat *convChat = purple_conversation_get_chat_data(conv);
+ char *uid = NULL;
+
NSString *normalizedUID;
if (prpl_info && prpl_info->get_cb_real_name) {
// Get the real name of the buddy for use as a UID, if available.
- char *uid = prpl_info->get_cb_real_name(purple_account_get_connection(account),
- purple_conv_chat_get_id(convChat),
- who);
-
- normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, uid)];
-
- // We have to free the result of get_cb_real_name.
- g_free(uid);
- } else {
- // Otherwise use the normalized name for the UID.
- normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, who)];
+ uid = prpl_info->get_cb_real_name(purple_account_get_connection(account),
+ purple_conv_chat_get_id(convChat),
+ who);
}
+ if (!uid) {
+ // strdup it, mostly so the free below won't have to be cased out.
+ uid = g_strdup(who);
+ }
+
+ normalizedUID = [NSString stringWithUTF8String:purple_normalize(account, uid)];
+
+ // We have to free the result of get_cb_real_name.
+ g_free(uid);
+
return normalizedUID;
}
More information about the commits
mailing list