changeset 10470:eaa9552a5e0f

[gaim-migrate @ 11752] Fix sf patch #1094564, from Evan Schoenberg Basically our ft API allows the filename to be NULL, but there are times when we attempt to print the filename and don't check if it's NULL first. This apparently sometimes causes crashes (on win32, OSX, Solaris, and I guess any other OS that doesn't let you printf("%s", NULL); committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 04 Jan 2005 01:58:36 +0000
parents 51b87da4e9f0
children 01558a7faa01
files src/ft.c
diffstat 1 files changed, 41 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/ft.c	Tue Jan 04 01:38:26 2005 +0000
+++ b/src/ft.c	Tue Jan 04 01:58:36 2005 +0000
@@ -253,15 +253,21 @@
 	/* If we have already accepted the request, ask the destination file
 	   name directly */
 	if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
-		size = gaim_xfer_get_size(xfer);
-		size_buf = gaim_str_size_to_units(size);
-
-		escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
-		buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
-				      xfer->who, escaped,
-				      size_buf);
-		g_free(size_buf);
-		g_free(escaped);
+		if (gaim_xfer_get_filename(xfer) != NULL)
+		{
+			size = gaim_xfer_get_size(xfer);
+			size_buf = gaim_str_size_to_units(size);
+			escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
+			buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
+					      xfer->who, escaped,
+					      size_buf);
+			g_free(size_buf);
+			g_free(escaped);
+		}
+		else
+		{
+			buf = g_strdup_printf(_("%s wants to send you a file"), xfer->who);
+		}
 
 		if (xfer->message != NULL)
 			serv_got_im(gaim_account_get_connection(xfer->account),
@@ -867,8 +873,11 @@
 		return;
 	}
 
-	msg = g_strdup_printf(_("Transfer of %s complete"),
-						  gaim_xfer_get_filename(xfer));
+	if (gaim_xfer_get_filename(xfer) != NULL)
+		msg = g_strdup_printf(_("Transfer of file %s complete"),
+							  gaim_xfer_get_filename(xfer));
+	else
+		msg = g_strdup_printf(_("File transfer complete"));
 	gaim_xfer_conversation_write(xfer, msg, FALSE);
 	g_free(msg);
 
@@ -914,10 +923,17 @@
 
 	gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
 
-	escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
-	msg = g_strdup_printf(_("You canceled the transfer of %s"),
-						  escaped);
-	g_free(escaped);
+	if (gaim_xfer_get_filename(xfer) != NULL)
+	{
+		escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
+		msg = g_strdup_printf(_("You canceled the transfer of %s"),
+							  escaped);
+		g_free(escaped);
+	}
+	else
+	{
+		msg = g_strdup_printf(_("File transfer cancelled"));
+	}
 	gaim_xfer_conversation_write(xfer, msg, FALSE);
 	g_free(msg);
 
@@ -966,9 +982,16 @@
 	gaim_request_close_with_handle(xfer);
 	gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE);
 
-	escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
-	msg = g_strdup_printf(_("%s canceled the transfer of %s"),
-						  xfer->who, escaped);
+	if (gaim_xfer_get_filename(xfer) != NULL)
+	{
+		escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
+		msg = g_strdup_printf(_("%s canceled the transfer of %s"),
+							  xfer->who, escaped);
+	}
+	else
+	{
+		msg = g_strdup_printf(_("%s canceled the file transfer"), xfer->who);
+	}
 	g_free(escaped);
 	gaim_xfer_conversation_write(xfer, msg, TRUE);
 	gaim_xfer_error(gaim_xfer_get_type(xfer), xfer->who, msg);