changeset 15009:c6fd017c4121

[gaim-migrate @ 17790] Part of SF Patch #1599432 from Leonardo Fernandes "This patch ... solves a check for NULL that produced an error in the debug console." committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 20 Nov 2006 05:33:32 +0000
parents 7589733ba1aa
children 4ae3c761455b
files COPYRIGHT libgaim/plugins/log_reader.c
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Mon Nov 20 04:05:33 2006 +0000
+++ b/COPYRIGHT	Mon Nov 20 05:33:32 2006 +0000
@@ -103,6 +103,7 @@
 Gábor Farkas
 Jesse Farmer
 Gavan Fantom (gavan)
+Leonardo Fernandes
 David Fiander
 Rob Flynn <gaim@robflynn.com>
 Rob Foehl (rwf)
--- a/libgaim/plugins/log_reader.c	Mon Nov 20 04:05:33 2006 +0000
+++ b/libgaim/plugins/log_reader.c	Mon Nov 20 05:33:32 2006 +0000
@@ -973,7 +973,8 @@
 
 			if (friendly_name != NULL) {
 				int friendly_name_length = strlen(friendly_name);
-				int alias_length         = log->account->alias ? strlen(log->account->alias) : 0;
+				const char *alias;
+				int alias_length;
 				GaimBuddy *buddy = gaim_find_buddy(log->account, log->name);
 				gboolean from_name_matches;
 				gboolean to_name_matches;
@@ -981,6 +982,17 @@
 				if (buddy && buddy->alias)
 					their_name = buddy->alias;
 
+				if (log->account->alias)
+				{
+					alias = log->account->alias;
+					alias_length = strlen(alias);
+				}
+				else
+				{
+					alias = "";
+					alias_length = 0;
+				}
+
 				/* Try to guess which user is me.
 				 * The first step is to determine if either of the names matches either my
 				 * friendly name or alias. For this test, "match" is defined as:
@@ -988,13 +1000,13 @@
 				 */
 				from_name_matches = (gaim_str_has_prefix(from_name, friendly_name) &&
 				                      !isalnum(*(from_name + friendly_name_length))) ||
-				                     (gaim_str_has_prefix(from_name, log->account->alias) &&
+				                     (gaim_str_has_prefix(from_name, alias) &&
 				                      !isalnum(*(from_name + alias_length)));
 
 				to_name_matches = to_name != NULL && (
 				                   (gaim_str_has_prefix(to_name, friendly_name) &&
 				                    !isalnum(*(to_name + friendly_name_length))) ||
-				                   (gaim_str_has_prefix(to_name, log->account->alias) &&
+				                   (gaim_str_has_prefix(to_name, alias) &&
 				                    !isalnum(*(to_name + alias_length))));
 
 				if (from_name_matches) {