Fixed: purple_group_get_name() NULL pointer dereference
authorHarvie <tomas@mudrunka.cz>
Mon, 21 Feb 2011 12:30:41 +0000 (13:30 +0100)
committerHarvie <tomas@mudrunka.cz>
Mon, 21 Feb 2011 12:30:41 +0000 (13:30 +0100)
README.md
answerscripts.c

index 5d5856bc06233905816aaad8ad84dc1e6fc6abe6..537540367bfea2712978035ebe60d4fecc298a82 100644 (file)
--- 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)
index 071ef97c1152a60b07cda64a67a4e5929b7bfc0d..59ac0d36d38d88efbad99cafa621b88beeda91a1 100755 (executable)
@@ -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
This page took 0.12812 seconds and 4 git commands to generate.