Blame SOURCES/0020-Add-g_return_if_fail-guards-to-file-xfer-public-func.patch

a547b4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a547b4
From: Christophe Fergeau <cfergeau@redhat.com>
a547b4
Date: Thu, 27 Feb 2014 18:45:15 +0100
a547b4
Subject: [PATCH] Add g_return_if_fail() guards to file xfer public functions
a547b4
a547b4
With the next commit, we won't always have a file xfer object available.
a547b4
This next commit will make sure NULL is never passed to the public file
a547b4
xfer functions, but it's safer to guard against that anyway in case
a547b4
this gets broken in the future.
a547b4
a547b4
(cherry picked from commit ec9f11064efee2ad3f0be0d36f5fdbbbe2d51ad9)
a547b4
---
a547b4
 src/vdagent-file-xfers.c | 10 ++++++++++
a547b4
 1 file changed, 10 insertions(+)
a547b4
a547b4
diff --git a/src/vdagent-file-xfers.c b/src/vdagent-file-xfers.c
a547b4
index 4dea6de..d59910b 100644
a547b4
--- a/src/vdagent-file-xfers.c
a547b4
+++ b/src/vdagent-file-xfers.c
a547b4
@@ -97,6 +97,8 @@ struct vdagent_file_xfers *vdagent_file_xfers_create(
a547b4
 
a547b4
 void vdagent_file_xfers_destroy(struct vdagent_file_xfers *xfers)
a547b4
 {
a547b4
+    g_return_if_fail(xfers != NULL);
a547b4
+
a547b4
     g_hash_table_destroy(xfers->xfers);
a547b4
     g_free(xfers->save_dir);
a547b4
     g_free(xfers);
a547b4
@@ -107,6 +109,8 @@ AgentFileXferTask *vdagent_file_xfers_get_task(
a547b4
 {
a547b4
     AgentFileXferTask *task;
a547b4
 
a547b4
+    g_return_val_if_fail(xfers != NULL, NULL);
a547b4
+
a547b4
     task = g_hash_table_lookup(xfers->xfers, GUINT_TO_POINTER(id));
a547b4
     if (task == NULL)
a547b4
         syslog(LOG_ERR, "file-xfer: error can not find task %u", id);
a547b4
@@ -173,6 +177,8 @@ void vdagent_file_xfers_start(struct vdagent_file_xfers *xfers,
a547b4
     struct stat st;
a547b4
     int i;
a547b4
 
a547b4
+    g_return_if_fail(xfers != NULL);
a547b4
+
a547b4
     if (g_hash_table_lookup(xfers->xfers, GUINT_TO_POINTER(msg->id))) {
a547b4
         syslog(LOG_ERR, "file-xfer: error id %u already exists, ignoring!",
a547b4
                msg->id);
a547b4
@@ -246,6 +252,8 @@ void vdagent_file_xfers_status(struct vdagent_file_xfers *xfers,
a547b4
 {
a547b4
     AgentFileXferTask *task;
a547b4
 
a547b4
+    g_return_if_fail(xfers != NULL);
a547b4
+
a547b4
     task = vdagent_file_xfers_get_task(xfers, msg->id);
a547b4
     if (!task)
a547b4
         return;
a547b4
@@ -267,6 +275,8 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
a547b4
     AgentFileXferTask *task;
a547b4
     int len, status = -1;
a547b4
 
a547b4
+    g_return_if_fail(xfers != NULL);
a547b4
+
a547b4
     task = vdagent_file_xfers_get_task(xfers, msg->id);
a547b4
     if (!task)
a547b4
         return;