Re: [gtk-list] Re: Bug in gtkclist: cell_set_text and friends.

Tim Janik <> writes:

> there are a *lot* of places in gtk that will produce a segmentation fault
> with code like this. really checking for new_pointer!=pointer wouldn't
> always do the trick imagine:
> s = _get_title();
> if (s &&
>     s[0]=='G' &&
>     s[1]=='t' &&
>     s[2]=='k')
>   set_title(s + 3);

Good point.  I guess I just hadn't gotten it into my head that in most
cases, you really *must* copy the strings handed back to you from the
"get" routines since what gtk might or might not do with them later is
undefined.  I had just assumed that *any* valid string would be OK for
the "set" routines.

In C I should know better.  I guess I've just been doing too much
Scheme programming recently.  (I really *hate* pointless memory
allocation issues.  Such a waste of good time...  Oh well, sorry to
gripe, not your fault, and as far as C goes, GTK's doing an excellent

Thanks for the responses.

Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.

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