comparison src/ft.c @ 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 1aa83016fbe0
children 1a97d5e88d12
comparison
equal deleted inserted replaced
10469:51b87da4e9f0 10470:eaa9552a5e0f
251 size_t size; 251 size_t size;
252 252
253 /* If we have already accepted the request, ask the destination file 253 /* If we have already accepted the request, ask the destination file
254 name directly */ 254 name directly */
255 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) { 255 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
256 size = gaim_xfer_get_size(xfer); 256 if (gaim_xfer_get_filename(xfer) != NULL)
257 size_buf = gaim_str_size_to_units(size); 257 {
258 258 size = gaim_xfer_get_size(xfer);
259 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); 259 size_buf = gaim_str_size_to_units(size);
260 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), 260 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
261 xfer->who, escaped, 261 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
262 size_buf); 262 xfer->who, escaped,
263 g_free(size_buf); 263 size_buf);
264 g_free(escaped); 264 g_free(size_buf);
265 g_free(escaped);
266 }
267 else
268 {
269 buf = g_strdup_printf(_("%s wants to send you a file"), xfer->who);
270 }
265 271
266 if (xfer->message != NULL) 272 if (xfer->message != NULL)
267 serv_got_im(gaim_account_get_connection(xfer->account), 273 serv_got_im(gaim_account_get_connection(xfer->account),
268 xfer->who, xfer->message, 0, time(NULL)); 274 xfer->who, xfer->message, 0, time(NULL));
269 275
865 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_DONE) { 871 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_DONE) {
866 gaim_xfer_cancel_local(xfer); 872 gaim_xfer_cancel_local(xfer);
867 return; 873 return;
868 } 874 }
869 875
870 msg = g_strdup_printf(_("Transfer of %s complete"), 876 if (gaim_xfer_get_filename(xfer) != NULL)
871 gaim_xfer_get_filename(xfer)); 877 msg = g_strdup_printf(_("Transfer of file %s complete"),
878 gaim_xfer_get_filename(xfer));
879 else
880 msg = g_strdup_printf(_("File transfer complete"));
872 gaim_xfer_conversation_write(xfer, msg, FALSE); 881 gaim_xfer_conversation_write(xfer, msg, FALSE);
873 g_free(msg); 882 g_free(msg);
874 883
875 if (xfer->ops.end != NULL) 884 if (xfer->ops.end != NULL)
876 xfer->ops.end(xfer); 885 xfer->ops.end(xfer);
912 921
913 g_return_if_fail(xfer != NULL); 922 g_return_if_fail(xfer != NULL);
914 923
915 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); 924 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
916 925
917 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); 926 if (gaim_xfer_get_filename(xfer) != NULL)
918 msg = g_strdup_printf(_("You canceled the transfer of %s"), 927 {
919 escaped); 928 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
920 g_free(escaped); 929 msg = g_strdup_printf(_("You canceled the transfer of %s"),
930 escaped);
931 g_free(escaped);
932 }
933 else
934 {
935 msg = g_strdup_printf(_("File transfer cancelled"));
936 }
921 gaim_xfer_conversation_write(xfer, msg, FALSE); 937 gaim_xfer_conversation_write(xfer, msg, FALSE);
922 g_free(msg); 938 g_free(msg);
923 939
924 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) 940 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
925 { 941 {
964 g_return_if_fail(xfer != NULL); 980 g_return_if_fail(xfer != NULL);
965 981
966 gaim_request_close_with_handle(xfer); 982 gaim_request_close_with_handle(xfer);
967 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE); 983 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE);
968 984
969 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); 985 if (gaim_xfer_get_filename(xfer) != NULL)
970 msg = g_strdup_printf(_("%s canceled the transfer of %s"), 986 {
971 xfer->who, escaped); 987 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
988 msg = g_strdup_printf(_("%s canceled the transfer of %s"),
989 xfer->who, escaped);
990 }
991 else
992 {
993 msg = g_strdup_printf(_("%s canceled the file transfer"), xfer->who);
994 }
972 g_free(escaped); 995 g_free(escaped);
973 gaim_xfer_conversation_write(xfer, msg, TRUE); 996 gaim_xfer_conversation_write(xfer, msg, TRUE);
974 gaim_xfer_error(gaim_xfer_get_type(xfer), xfer->who, msg); 997 gaim_xfer_error(gaim_xfer_get_type(xfer), xfer->who, msg);
975 g_free(msg); 998 g_free(msg);
976 999