check that filename pointer is non-NULL before using it, not after (coverity warning); don't pass NULL fp to fclose()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-03-30 13:06:29 +00:00
parent 61011e917f
commit 4b5a7d3d09

View File

@ -181,18 +181,23 @@ void gtk_assert_dialog_save_backtrace_callback (GtkWidget *widget, GtkAssertDial
FILE *fp;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
msg = gtk_assert_dialog_get_message (dlg);
backtrace = gtk_assert_dialog_get_backtrace (dlg);
if ( filename )
{
msg = gtk_assert_dialog_get_message (dlg);
backtrace = gtk_assert_dialog_get_backtrace (dlg);
/* open the file and write all info inside it */
fp = fopen (filename, "w");
if (fp)
fprintf (fp, "ASSERT INFO:\n%s\n\nBACKTRACE:\n%s", msg, backtrace);
/* open the file and write all info inside it */
fp = fopen (filename, "w");
if (fp)
{
fprintf (fp, "ASSERT INFO:\n%s\n\nBACKTRACE:\n%s", msg, backtrace);
fclose (fp);
}
g_free (filename);
g_free (msg);
g_free (backtrace);
fclose (fp);
g_free (filename);
g_free (msg);
g_free (backtrace);
}
}
gtk_widget_destroy (dialog);