[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 29/43] qom: dynamic_cast of NULL is always NULL
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 29/43] qom: dynamic_cast of NULL is always NULL |
Date: |
Mon, 3 Dec 2012 16:25:45 -0600 |
From: Paolo Bonzini <address@hidden>
Trying to cast a NULL value will cause a crash. Returning
NULL is also sensible, and it is also what the type-unsafe
DO_UPCAST macro does.
Reported-by: Markus Armbruster <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
(cherry picked from commit b7f43fe46029d8fd0594cd599fa2599dcce0f553)
Signed-off-by: Michael Roth <address@hidden>
---
qom/object.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index e3e9242..f33e84d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -417,7 +417,7 @@ void object_delete(Object *obj)
Object *object_dynamic_cast(Object *obj, const char *typename)
{
- if (object_class_dynamic_cast(object_get_class(obj), typename)) {
+ if (obj && object_class_dynamic_cast(object_get_class(obj), typename)) {
return obj;
}
@@ -430,7 +430,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char
*typename)
inst = object_dynamic_cast(obj, typename);
- if (!inst) {
+ if (!inst && obj) {
fprintf(stderr, "Object %p is not an instance of type %s\n",
obj, typename);
abort();
--
1.7.9.5
- [Qemu-devel] [PATCH 16/43] xhci: fix usb name in caps, (continued)
- [Qemu-devel] [PATCH 16/43] xhci: fix usb name in caps, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 14/43] PPC: Bamboo: Fix memory size DT property, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 17/43] tools: initialize main loop before block layer, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 19/43] nbd: fixes to read-only handling, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 18/43] m68k: Return semihosting errno values correctly, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 20/43] mips/malta: fix CBUS UART interrupt pin, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 21/43] target-mips: fix wrong microMIPS opcode encoding, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 23/43] tcg/arm: fix cross-endian qemu_st16, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 22/43] tcg/arm: fix TLB access in qemu-ld/st ops, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 28/43] block: Fix regression for MinGW (assertion caused by short string), Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 27/43] tci: Fix type of tci_read_label, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 26/43] qcow2: Fix refcount table size calculation, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 34/43] qapi: fix qapi_dealloc_type_size parameter type, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 33/43] qapi: handle visitor->type_size() in QapiDeallocVisitor, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 35/43] iscsi: fix segfault in url parsing, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 37/43] iscsi: do not assume device is zero initialized, Michael Roth, 2012/12/03
- [Qemu-devel] [PATCH 36/43] iscsi: fix deadlock during login, Michael Roth, 2012/12/03