http://developer.pidgin.im/ticket/2337

Richard Laager rlaager at wiktel.com
Sun Sep 16 14:46:24 EDT 2007


On Sun, 2007-09-16 at 11:27 -0700, Sean Egan wrote:
> Does anyone have an answer to http://developer.pidgin.im/ticket/2337 ?

I left a couple of comments there.

While looking, I found this:

        /*
         * Plugin stuff. we pass a char ** but we don't want to pass what's
         * been given us by the prpls. So we create temp holders and pass
         * those instead. It's basically just to avoid segfaults.
         */
        /* TODO: MAX(message, BUF_LONG) is pretty ugly. */
        buffy = g_malloc(MAX(strlen(msg) + 1, BUF_LONG));
        strcpy(buffy, msg);
        angel = g_strdup(who);

        plugin_return = GPOINTER_TO_INT(
                purple_signal_emit_return_1(purple_conversations_get_handle(),
                                                                  "receiving-im-msg", gc->account,
                                                                  &angel, &buffy, cnv, &flags));

Why are we passing a minimum of a BUF_LONG buffer? If anything, why not
just do buffy = g_strdup(msg)? I don't think we should be attempting to
prevent segfaults by passing a big buffer to plugins so they can stomp
around as they please. If the plugin wants to return a longer string,
then they can g_strdup() it themselves, free the old one, and set the
pointer to their new memory. That's how I've seen everything do it.

Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://pidgin.im/pipermail/devel/attachments/20070916/7ff51c08/attachment.sig>


More information about the Devel mailing list