In message <1112223809.3671.7.camel@xxxxxxxxxxxxxxxxxxxxx>, Ray Strode writes: >> 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. It's an incredibly wasteful exercise to criticize three lines of code that was intended to demonstrate that a stable (5+ year old) library was broken. I provided a test case that was part of a far larger project, approximately 200,000 lines of code and 3.5 MB of Glade files. Every project that large has flaws, but even if that microscopic and unused part of our project was written to the high standards of the used parts of the project, the gnome-libs library would still have crashed. I'm sure you are a wonderful programmer, but your programming lessons are misdirected. John -- John GOTTS <jgotts@xxxxxxxxxxxxxx> http://linuxsavvy.com/staff/jgotts