]> granicus.if.org Git - transmission/commitdiff
fix a handful of console warnings that were generated by trying to trash a NULL ...
authorJordan Lee <jordan@transmissionbt.com>
Sun, 23 Sep 2012 15:38:07 +0000 (15:38 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sun, 23 Sep 2012 15:38:07 +0000 (15:38 +0000)
gtk/tr-core.c
gtk/util.c

index 3319c2f93669721561a9ee9f225465c328a03bc0..f30ce95f3dde51b13dc75011cf1d9597cebed39c 100644 (file)
@@ -984,11 +984,14 @@ core_create_new_torrent( TrCore * core, tr_ctor * ctor )
     {
         const char * config = tr_sessionGetConfigDir( session );
         const char * source = tr_ctorGetSourceFile( ctor );
-        const int is_internal = source && ( strstr( source, config ) == source );
 
-        /* #1294: don't delete the .torrent file if it's our internal copy */
-        if( !is_internal )
-            gtr_file_trash_or_remove( source );
+        if( source != NULL )
+        {
+          /* #1294: don't delete the .torrent file if it's our internal copy */
+          const int is_internal = ( strstr( source, config ) == source );
+          if( !is_internal )
+              gtr_file_trash_or_remove( source );
+        }
     }
 
     return tor;
index 1427811041e95711612d1337b2d8ff4e37a30314..8e669ba727cd373ebfff970aa9dd5de6aa232092 100644 (file)
@@ -299,8 +299,12 @@ on_tree_view_button_released( GtkWidget *      view,
 int
 gtr_file_trash_or_remove( const char * filename )
 {
+    GFile * file;
     gboolean trashed = FALSE;
-    GFile * file = g_file_new_for_path( filename );
+
+    g_return_val_if_fail (filename && *filename, 0);
+
+    file = g_file_new_for_path( filename );
 
     if( gtr_pref_flag_get( PREF_KEY_TRASH_CAN_ENABLED ) ) {
         GError * err = NULL;