The 'arg' member of arguments and the 'dir' member of char_directives
are only allocated from malloc() if there are more than fit in the
arrays that are included inside their respective structures, so they
must only be freed when that internal structure is not used.
Also, these arrays are allocated with malloc() and so must be freed
with free(), not g_free().
Thanks to Benoit Flippen <anagogue@gmail.com> for reporting the
problem.
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2009 Free Software Foundation
+ Copyright (C) 2007, 2009, 2011 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+ if (a.arg != a.direct_alloc_arg)
+ free (a.arg);
output = g_string_sized_new (strlen (fmt));
output = g_string_sized_new (strlen (fmt));
+ if (d.dir != d.direct_alloc_dir)
+ free (d.dir);
if (*s)
g_string_append_len (output, s, -1);
if (*s)
g_string_append_len (output, s, -1);
if ( 0 != printf_parse (fmt, &d, &a) )
return NULL;
if ( 0 != printf_parse (fmt, &d, &a) )
return NULL;
+ if (a.arg != a.direct_alloc_arg)
+ free (a.arg);
+ if (d.dir != d.direct_alloc_dir)
+ free (d.dir);