diff --git a/src/util/virobject.c b/src/util/virobject.c index 808edc4837da9d3b1dc8ebbac4a6e29c37813cd9..93e37e4a5d968c85f2bfa153a77b4d74d3c2f2f9 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -186,13 +186,13 @@ bool virClassIsDerivedFrom(virClassPtr klass, void *virObjectNew(virClassPtr klass) { virObjectPtr obj = NULL; - char *somebytes; - if (VIR_ALLOC_N(somebytes, klass->objectSize) < 0) { + if (VIR_ALLOC_VAR(obj, + char, + klass->objectSize - sizeof(virObject)) < 0) { virReportOOMError(); return NULL; } - obj = (virObjectPtr)somebytes; obj->magic = klass->magic; obj->klass = klass;