[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debugging the gtk fe



On Thu, Jul 28, 2005 at 11:45:03AM -0400, Mike Emmel wrote:
> On 7/28/05, fiandro@tiscali.it <fiandro@tiscali.it> wrote:
> > As i told you before i'm not very good at debugging code, but from your message
> > i've seen the problem is related to argc and argv pointers: they are hand-created
> > at line 1370 of gtk.c this way
> > 
> >     /* FIXME: This can surely be done in a better way */
> >     (char**) name = malloc(2 * sizeof(char*));
> >     (char*) name[0] = malloc(8 * sizeof(char));
> >     name[0] = "debconf";
> >     name[1] = NULL;
> > 
> > and used this way
> > 
> >     gtk_init (&args, &name);
> > 
> > those lines used to be cause of some  (not many)     strange crashes even
> > in an X environment.
> > may be this related to the  crashes?
> 
> Yep you forgot to allocate space for the terminal \0 and set it.
> name[0] = malloc(10 * sizeof(char));
> memset(name[0],10,sizeof(char);

That's clearly wrong, as (a) 8 == strlen("debconf") + 1, (b) the string
literal "debconf" includes a trailing '\0', (c) name[0] gets overwritten
by the assignment anyway so that malloc is entirely irrelevant. Anyway,
as I said in my other mail, I've made the code more normal in trunk.

Cheers,

-- 
Colin Watson                                       [cjwatson@debian.org]



Reply to: