Issue #4536 - Seg fault when trying to open image on Google Drive (Gnome 3.34.3)

In file_open_image(), mount non-native files *before* looking up a
file-proc.  Previously, we'd only mount the file after the initial
lookup, and fail to perform a second lookup if the mount succeeded,
leaving us with a NULL file-proc and a subsequent segfault.

Additionally, simplify the rest of the remote-file code-path.
This commit is contained in:
Ell 2020-07-28 10:50:29 +03:00
parent 1ac4a8f890
commit 0829dba97f
1 changed files with 33 additions and 39 deletions

View File

@ -96,6 +96,26 @@ file_open_image (Gimp *gimp,
orig_file = file;
if (! g_file_is_native (file) &&
! file_remote_mount_file (gimp, file, progress, &my_error))
{
if (my_error)
{
g_printerr ("%s: mounting remote volume failed, trying to download"
"the file: %s\n",
G_STRFUNC, my_error->message);
g_clear_error (&my_error);
mounted = FALSE;
}
else
{
*status = GIMP_PDB_CANCEL;
return NULL;
}
}
/* FIXME enable these tests for remote files again, needs testing */
if (g_file_is_native (file) &&
g_file_query_exists (file, NULL))
@ -135,43 +155,14 @@ file_open_image (Gimp *gimp,
GIMP_FILE_PROCEDURE_GROUP_OPEN,
file, error);
if (! file_proc)
{
/* don't bail out on remote files, they might need to be
* downloaded for magic matching
*/
if (g_file_is_native (file))
return NULL;
g_clear_error (error);
}
if (! g_file_is_native (file) &&
! file_remote_mount_file (gimp, file, progress, &my_error))
{
if (my_error)
{
g_printerr ("%s: mounting remote volume failed, trying to download"
"the file: %s\n",
G_STRFUNC, my_error->message);
g_clear_error (&my_error);
mounted = FALSE;
}
else
{
*status = GIMP_PDB_CANCEL;
return NULL;
}
}
if (! file_proc || ! file_proc->handles_remote || ! mounted)
{
gchar *my_path = g_file_get_path (file);
if (! my_path)
{
g_clear_error (error);
local_file = file_remote_download_image (gimp, file, progress,
&my_error);
@ -193,20 +184,23 @@ file_open_image (Gimp *gimp,
GIMP_FILE_PROCEDURE_GROUP_OPEN,
local_file, error);
if (! file_proc)
{
g_file_delete (local_file, NULL, NULL);
g_object_unref (local_file);
return NULL;
}
file = local_file;
}
g_free (my_path);
}
if (! file_proc)
{
if (local_file)
{
g_file_delete (local_file, NULL, NULL);
g_object_unref (local_file);
}
return NULL;
}
if (progress)
g_object_add_weak_pointer (G_OBJECT (progress), (gpointer) &progress);