Plugin Development. Plugin crashes

Sadrul Habib Chowdhury imadil at
Mon Oct 3 17:45:20 EDT 2011

On Sat, Oct 1, 2011 at 3:13 PM, Munawwar <munawwarfiroz at> wrote:
> Been developing a Pidgin plugin (on and off for weeks). The plugin is to
> show a popup window displaying the emails which the user has received.
> Internally when a set of emails are recieved, I am allocating heap space and
> appending the info into a list (glib singly-linked list).
> The problem:
> When an email is recieved, it shows the window as expected. However, when
> the next mail is received, I intend the window to close, deallocate memory,
> then repeat the procedure as it was done for the first mail (allocate memory
> and show window). but it crashes at line number 130.
> Source code:
> Crash report and debug messages:
> OS: Windows 7
> Pidgin version: 2.10.0
> MinGW, GCC compiler: 4.4.0
> Seems very odd, since line number 130 isn't trying to dereference nor free
> anything.
> Any theories?

In case you are still working on this: it looks like you are not
allocating enough memory for pn_Mail::subject, from, to, url fields;
malloc(strlen(src)) does not allocate memory for the NULL terminating
the string, so you can end up corrupting memory (e.g. the subsequent
strcpy, or sprintf in line 214). If you update the malloc to allocate
strlen(src) + 1 bytes, then things should improve. However, I will
strongly encourage you to use g_strdup here instead (and g_snprintf or
snprintf instead of sprintf). Note that if you do use g_strdup, you
will want to 'g_free' the memory (instead of 'free').


> Regards,
> Munawwar
> _______________________________________________
> Devel mailing list
> Devel at

More information about the Devel mailing list