FC3: gnome-libs API broken with 1.4.1.2.90-32
Ray Strode
rstrode at redhat.com
Wed Mar 30 23:03:29 UTC 2005
Hi,
> We've had the same code in our software since 2000:
>
> GnomeFileEntry *fe;
> gchar buf[1024];
>
> ---> sprintf(buf, "%s", gnome_file_entry_get_full_path(fe, TRUE));
>
...
> if (strcmp(buf, "(null)") == 0)
> *buf = '\0';
get_full_path allocates memory for you. sprintf is a bad idea because
there is no bounds checking, you're leaking the memory that
get_full_path allocates, and you're not supposed to pass NULL to sprintf
when it wants a character array. doing if (strcmp(buf, "(null)") is
bad, too.
instead do:
gchar *buf;
...
buf = gnome_file_entry_get_full_path (fe, TRUE));
Then you can check for NULL;
if (buf == NULL)
buf = g_strdup ("");
and then call g_free when you're done with it.
> Fortunately, the file entry widget was for
> future use, so I completely removed its use in our code.
That's an even better idea.
--Ray
More information about the fedora-devel-list
mailing list