mark at kingant.net
Thu Sep 20 02:29:55 EDT 2007
On Sun, 16 Sep 2007 13:46:24 -0500, Richard Laager wrote
> 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(
> "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.
I agree, that was pretty silly. I just changed it to g_strdup(message);
More information about the Devel