On Tue, 22 Apr 2003 07:53:55 +0200 (CEST), Romain LIEVIN wrote:
> > I'm getting an error when I try to access the User Manual from the
> > help menu
> >
> > tilp free: junk pointer (too high to make sense)
> >
> > The problem is with a g_strfreev() call. At first sight there don't
> > seem to be any problems with this function at other places, so I was
> > wondering if anybody else has this too.
>
> I noticed problems with this function. This is the reason why it's
> replaced by a set of free() calls somewhere in the source code.
>
> This function worked fine before or I am mis-using it...
>
> Anyways, it's a bug to fix. Thanks !
It's because of the array notation. An array of pointers and a double
pointer (with a malloc) aren't the same.
Because it's a local variable in a function, the entire array is stored
on the stack, whereas with the pointer notation, only the value of the
pointer is stored. I bet "g_strfreev()" gives the error when it tries to
free mem from the stack.
So, to get rid of this, we could use something like this:
void ....{
gchar **argv = (gchar *) malloc(3 * sizeof(gchar *));
argv[0] = g_strdup(...);
argv[1] = ...;
argv[2] = NULL;
g_strfreev(argv);
}
|