From 2c80caf35108007dca2dcec69d7a325787309763 Mon Sep 17 00:00:00 2001 From: Harvie Date: Mon, 21 Feb 2011 13:30:41 +0100 Subject: [PATCH] Fixed: purple_group_get_name() NULL pointer dereference --- README.md | 2 +- answerscripts.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d5856b..5375403 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ There are lot of hacks that you can do with this simple framework if you know so * Following **environment values are passed** to the script: * ANSW\_MSG (text of the message) * ANSW\_FROM (who sent you the message) - * ANSW\_FROM\_GROUP (group which contains that buddy - buggy) + * ANSW\_FROM\_GROUP (group which contains that buddy) * ANSW\_PROTOCOL (protocol used to deliver the message. eg.: xmpp, irc,...) * ANSW\_STATUS (unique ID of status. eg.: available, away,...) * ANSW\_STATUS\_MSG (status message set by user) diff --git a/answerscripts.c b/answerscripts.c index 071ef97..59ac0d3 100755 --- a/answerscripts.c +++ b/answerscripts.c @@ -90,7 +90,8 @@ static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer, setenv(ENV_PREFIX "REMOTE_ALIAS", remote_alias, 1); //??? //Get buddy group - const char *from_group = purple_group_get_name(purple_buddy_get_group(buddy)); //FIXME: purple_group_get_name() returns "\x18" (or random data!) when user does not belong to some group + PurpleGroup *group = purple_buddy_get_group(buddy); + const char *from_group = group != NULL ? purple_group_get_name(group) : ""; //return empty string if not in group //Get protocol ID const char *protocol_id = purple_account_get_protocol_id(account); @@ -115,7 +116,7 @@ static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer, //Export variables to environment setenv(ENV_PREFIX "MSG", message, 1); //text of the message setenv(ENV_PREFIX "FROM", who, 1); //who sent you the message - setenv(ENV_PREFIX "FROM_GROUP", from_group, 1); //group which contains that buddy - buggy + setenv(ENV_PREFIX "FROM_GROUP", from_group, 1); //group which contains that buddy setenv(ENV_PREFIX "PROTOCOL", protocol_id, 1); //protocol used to deliver the message. eg.: xmpp, irc,... setenv(ENV_PREFIX "STATUS", status_id, 1); //unique ID of status. eg.: available, away,... setenv(ENV_PREFIX "STATUS_MSG", status_msg, 1); //status message set by user -- 2.30.2