[PATCH] esx: Fix dynamic dispatch for CastFromAnyType functions

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

 



This was broken by the refactoring in ac1e6586ec75. It resulted in a
segfault for 'virsh vol-dumpxml' and related volume functions.

Before the refactoring all users of the ESX_VI__TEMPLATE__DISPATCH
macro dispatched on the item type, as the item is the input to all those
functions.

Commit ac1e6586ec75 made the dynamically dispatched CastFromAnyType
functions use this macro too, but this functions dispatched on the
actual type of the AnyType object. The item is the output of the
CastFromAnyType functions.

This difference was missed in the refactoring, making CastFromAnyType
functions dereferencing the item pointer that is NULL at the time of
the dispatch.
---
 src/esx/esx_vi_types.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index dd83954..6a2d5cf 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -533,8 +533,8 @@
  * Macros to implement dynamic dispatched functions
  */
 
-#define ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, _error_return)          \
-    switch (item->_type) {                                                    \
+#define ESX_VI__TEMPLATE__DISPATCH(_object, __type, _dispatch, _error_return) \
+    switch ((_object)->_type) {                                               \
       _dispatch                                                               \
                                                                               \
       case esxVI_Type_##__type:                                               \
@@ -543,7 +543,7 @@
       default:                                                                \
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
                      _("Call to %s for unexpected type '%s'"), __FUNCTION__,  \
-                     esxVI_Type_ToString(item->_type));                       \
+                     esxVI_Type_ToString((_object)->_type));                  \
         return _error_return;                                                 \
     }
 
@@ -585,7 +585,7 @@
 
 #define ESX_VI__TEMPLATE__DYNAMIC_FREE(__type, _dispatch, _body)              \
     ESX_VI__TEMPLATE__FREE(__type,                                            \
-      ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, /* nothing */)            \
+      ESX_VI__TEMPLATE__DISPATCH(item, __type, _dispatch, /* nothing */)      \
       _body)
 
 
@@ -618,14 +618,14 @@
 
 #define ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(__type, _dispatch)       \
     ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(__type, esxVI_##__type,        \
-      ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1),                      \
+      ESX_VI__TEMPLATE__DISPATCH(anyType, __type, _dispatch, -1),             \
       /* nothing */)
 
 
 
 #define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize)    \
     ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type,                                 \
-      ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1),                      \
+      ESX_VI__TEMPLATE__DISPATCH(item, __type, _dispatch, -1),                \
       _serialize)
 
 
-- 
1.7.0.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]