Menu

Crashing while dealing with "sending-im-msg"

2007-03-02
2013-01-14
  • breathermachine

    breathermachine - 2007-03-02

    I'm making a text morphing plugin for gaim. Before it sends the message i typed, it will modify it through a callback function responding to the "sending-im-msg" signal.

    void sending_im_msg(GaimAccount *account, const char *receiver,
                           char **message);

    This is the callback prototype for that. The documentation at gaim.sourceforge.net says that you should free *message before replacing it with a new string.

    I tried this piece of code but it breaks my gaim.

        char *str;
        g_free(*message);
        str=g_malloc(13); //just enough for a 12-character, format-free text.
        strcpy(str,"Now more fun");
        message=str;

    Somehow this doesn't work in my system.
    Anyone help?
    Thanks

    Jay.

     
    • breathermachine

      breathermachine - 2007-03-02

      Ok got that thing corrected already.

      The problem with the code above is that message was told to point to a local variable which will become nonsensical after the function call.

          g_free(*message);
          (*message)=g_malloc(13);
          strcpy(*message,"Now more fun");

      This is the fix. Haha, I fixed my own code. LOL