[gvfs/mtp-backend: 62/64] MTP: Fix segfault if client queries for non-existent file by name.



commit f842c1581f4dc7ef85d737c7745516d6187fe930
Author: Philip Langdale <philipl overt org>
Date:   Fri Jan 4 20:01:05 2013 -0800

    MTP: Fix segfault if client queries for non-existent file by name.
    
    If the client, usually Nautilus, ends up trying to find a file
    by name instead of ID, there might not be a match. We should
    return NOT_FOUND explicitly, as there is no libmtp error generated
    in this case.
    
    This situation arises after:
    * A file is renamed
    * A directory is created
    * A file is created (which actually fails)
    
    Refreshing the Nautilus view will get Nautilus back in sync.

 daemon/gvfsbackendmtp.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 209118d..2c59fd7 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -933,6 +933,14 @@ do_query_info (GVfsBackend *backend,
         i = i->next;
         LIBMTP_destroy_file_t (tmp);
       }
+      if (file == NULL) {
+        /* The backup query might have found nothing. */
+        DEBUG ("(II) backup query could not find file");
+        g_vfs_job_failed_literal (G_VFS_JOB (job),
+                                  G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                                  _("File not found"));
+        goto exit;
+      }
     } else {
       file = LIBMTP_Get_Filemetadata (device, strtol (elements[ne-1], NULL, 10));
     }



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