Re: FC3: gnome-libs API broken with 1.4.1.2.90-32

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

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux