[PATCH v2 04/17] virdomainjob: add check for callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There may be a case that the callback structure will exist with
no callbacks (following patches). This patch adds check for
specific callbacks before using them.

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/conf/virdomainjob.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c
index 0515e1d507..5ab4bdc18b 100644
--- a/src/conf/virdomainjob.c
+++ b/src/conf/virdomainjob.c
@@ -138,7 +138,7 @@ virDomainObjInitJob(virDomainJobObj *job,
         return -1;
     }
 
-    if (job->cb &&
+    if (job->cb && job->cb->allocJobPrivate &&
         !(job->privateData = job->cb->allocJobPrivate())) {
         virCondDestroy(&job->cond);
         virCondDestroy(&job->asyncCond);
@@ -180,7 +180,7 @@ virDomainObjResetAsyncJob(virDomainJobObj *job)
     g_clear_pointer(&job->current, virDomainJobDataFree);
     job->apiFlags = 0;
 
-    if (job->cb)
+    if (job->cb && job->cb->resetJobPrivate)
         job->cb->resetJobPrivate(job->privateData);
 }
 
@@ -206,7 +206,7 @@ virDomainObjPreserveJob(virDomainJobObj *currJob,
     job->privateData = g_steal_pointer(&currJob->privateData);
     job->apiFlags = currJob->apiFlags;
 
-    if (currJob->cb &&
+    if (currJob->cb && currJob->cb->allocJobPrivate &&
         !(currJob->privateData = currJob->cb->allocJobPrivate()))
         return -1;
     job->cb = currJob->cb;
@@ -226,7 +226,7 @@ virDomainObjClearJob(virDomainJobObj *job)
     virCondDestroy(&job->cond);
     virCondDestroy(&job->asyncCond);
 
-    if (job->cb)
+    if (job->cb && job->cb->freeJobPrivate)
         g_clear_pointer(&job->privateData, job->cb->freeJobPrivate);
 }
 
-- 
2.37.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux