summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2012-07-27 16:03:48 +0200
committerTomas Bzatek <tbzatek@redhat.com>2012-07-31 11:59:38 +0200
commit59cda52b8d5e067c4fbdab1943fc90859ed0b97f (patch)
tree099f4cd80ca0c9d1669be38612eb4e8b252e6dee
parent6184b93b66d37ac101582eafb4dd39646811f54d (diff)
downloadgvfs-59cda52b8d5e067c4fbdab1943fc90859ed0b97f.tar.gz
gdbus: Don't use NULL values on error with fd passing
Found out that if the remote call fails, some variables are left uninitialized and causes assertion failures while we don't need them.
-rw-r--r--client/gdaemonfile.c26
-rw-r--r--client/gvfsiconloadable.c12
2 files changed, 16 insertions, 22 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index f94996ca..dac616dd 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -1148,8 +1148,7 @@ g_daemon_file_read (GFile *file,
gboolean can_seek;
GUnixFDList *fd_list;
int fd;
- GVariant *fd_id_val;
- guint fd_id;
+ GVariant *fd_id_val = NULL;
guint32 pid;
GError *local_error = NULL;
@@ -1173,9 +1172,6 @@ g_daemon_file_read (GFile *file,
g_print ("g_daemon_file_read: done, res = %d\n", res);
- fd_id = g_variant_get_handle (fd_id_val);
- g_variant_unref (fd_id_val);
-
if (! res)
{
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -1188,15 +1184,17 @@ g_daemon_file_read (GFile *file,
if (! res)
return NULL;
-
- if (fd_list == NULL || g_unix_fd_list_get_length (fd_list) != 1 ||
- (fd = g_unix_fd_list_get (fd_list, fd_id, NULL)) == -1)
+
+ if (fd_list == NULL || fd_id_val == NULL ||
+ g_unix_fd_list_get_length (fd_list) != 1 ||
+ (fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_id_val), NULL)) == -1)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Didn't get stream file descriptor"));
return NULL;
}
+ g_variant_unref (fd_id_val);
g_object_unref (fd_list);
return g_daemon_file_input_stream_new (fd, can_seek);
@@ -1217,8 +1215,7 @@ file_open_write (GFile *file,
gboolean can_seek;
GUnixFDList *fd_list;
int fd;
- GVariant *fd_id_val;
- guint32 fd_id;
+ GVariant *fd_id_val = NULL;
guint32 pid;
guint64 initial_offset;
GError *local_error = NULL;
@@ -1249,9 +1246,6 @@ file_open_write (GFile *file,
g_print ("file_open_write: done, res = %d\n", res);
- fd_id = g_variant_get_handle (fd_id_val);
- g_variant_unref (fd_id_val);
-
if (! res)
{
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -1265,14 +1259,16 @@ file_open_write (GFile *file,
if (! res)
return NULL;
- if (fd_list == NULL || g_unix_fd_list_get_length (fd_list) != 1 ||
- (fd = g_unix_fd_list_get (fd_list, 0, NULL)) == -1)
+ if (fd_list == NULL || fd_id_val == NULL ||
+ g_unix_fd_list_get_length (fd_list) != 1 ||
+ (fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_id_val), NULL)) == -1)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Didn't get stream file descriptor"));
return NULL;
}
+ g_variant_unref (fd_id_val);
g_object_unref (fd_list);
return g_daemon_file_output_stream_new (fd, can_seek, initial_offset);
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c
index 511090d8..70ee720b 100644
--- a/client/gvfsiconloadable.c
+++ b/client/gvfsiconloadable.c
@@ -93,8 +93,7 @@ g_vfs_icon_load (GLoadableIcon *icon,
gboolean can_seek;
GUnixFDList *fd_list;
int fd;
- GVariant *fd_id_val;
- guint32 fd_id;
+ GVariant *fd_id_val = NULL;
GError *local_error = NULL;
g_print ("gvfsiconloadable.c: g_vfs_icon_load\n");
@@ -114,9 +113,6 @@ g_vfs_icon_load (GLoadableIcon *icon,
g_print ("gvfsiconloadable.c: g_vfs_icon_load: done, res = %d\n", res);
- fd_id = g_variant_get_handle (fd_id_val);
- g_variant_unref (fd_id_val);
-
if (! res)
{
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -129,14 +125,16 @@ g_vfs_icon_load (GLoadableIcon *icon,
if (! res)
return NULL;
- if (fd_list == NULL || g_unix_fd_list_get_length (fd_list) != 1 ||
- (fd = g_unix_fd_list_get (fd_list, 0, NULL)) == -1)
+ if (fd_list == NULL || fd_id_val == NULL ||
+ g_unix_fd_list_get_length (fd_list) != 1 ||
+ (fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_id_val), NULL)) == -1)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Didn't get stream file descriptor"));
return NULL;
}
+ g_variant_unref (fd_id_val);
g_object_unref (fd_list);
return G_INPUT_STREAM (g_daemon_file_input_stream_new (fd, can_seek));