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

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