Re: Memory question



Dnia 2005-09-29 13:56, Christian Neumair napisaÅ:
Am Donnerstag, den 29.09.2005, 13:39 +0200 schrieb PrzemysÅaw Sitek:

Dnia 2005-09-29 21:41, Colossus napisaÅ:

Ok,

the correct way is to cast g_strerror to (char *):

response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,(char *) g_strerror(errno));

This way i don't get any warning.

But it's still incorrect. It should be

response = ShowGtkMessageDialog (GTK_WINDOW
        (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,
        "%s", g_strerror(errno));

printf-like functions shouldn't take random strings as their format
string, as they may contain format instructions (such as %s, %d etc)
which will cause the function to look for non-existent arguments which
will produce segfauls.


I wasn't aware that the called method has printf flavor. I wonder which
API provides ShowGtkMessageDialog.

AAARGH, I was thinking about gtk_message_dialog_new:-) My fault:-)

--
  PrzemysÂaw Sitek



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