[Spice-devel] [PATCH spice-gtk 2/2] file-transfer: Add guards to public functions

Pavel Grunt pgrunt at redhat.com
Thu Sep 1 09:33:14 UTC 2016


---
 src/spice-file-transfer-task.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
index 96aef9f..e3fbcc7 100644
--- a/src/spice-file-transfer-task.c
+++ b/src/spice-file-transfer-task.c
@@ -503,6 +503,8 @@ gboolean spice_file_transfer_task_is_completed(SpiceFileTransferTask *self)
  **/
 double spice_file_transfer_task_get_progress(SpiceFileTransferTask *self)
 {
+    g_return_val_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self), 0.0);
+
     if (self->file_size == 0)
         return 0.0;
 
@@ -522,6 +524,8 @@ double spice_file_transfer_task_get_progress(SpiceFileTransferTask *self)
  **/
 void spice_file_transfer_task_cancel(SpiceFileTransferTask *self)
 {
+    g_return_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self));
+
     g_cancellable_cancel(self->cancellable);
 }
 
@@ -537,6 +541,8 @@ void spice_file_transfer_task_cancel(SpiceFileTransferTask *self)
  **/
 char* spice_file_transfer_task_get_filename(SpiceFileTransferTask *self)
 {
+    g_return_val_if_fail(SPICE_IS_FILE_TRANSFER_TASK(self), NULL);
+
     return g_file_get_basename(self->file);
 }
 
-- 
2.9.3



More information about the Spice-devel mailing list