From 764d5617402572ad4c98dd3f3c7f2ba5a694f2d2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 9 Mar 2005 19:55:33 +0000 Subject: [PATCH] prevent crash when packing too much --- direct/src/dcparser/dcPacker.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index c7168661d2..4ef03bbfe1 100755 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -705,14 +705,17 @@ pack_object(PyObject *object) { bool is_instance = false; const DCClass *dclass = NULL; - const DCClassParameter *class_param = get_current_field()->as_class_parameter(); - if (class_param != (DCClassParameter *)NULL) { - dclass = class_param->get_class(); - - if (dclass->has_class_def()) { - PyObject *class_def = dclass->get_class_def(); - is_instance = (PyObject_IsInstance(object, dclass->get_class_def()) != 0); - Py_DECREF(class_def); + const DCPackerInterface *current_field = get_current_field(); + if (current_field != (DCPackerInterface *)NULL) { + const DCClassParameter *class_param = get_current_field()->as_class_parameter(); + if (class_param != (DCClassParameter *)NULL) { + dclass = class_param->get_class(); + + if (dclass->has_class_def()) { + PyObject *class_def = dclass->get_class_def(); + is_instance = (PyObject_IsInstance(object, dclass->get_class_def()) != 0); + Py_DECREF(class_def); + } } }