Browse Source

prevent crash when packing too much

David Rose 21 years ago
parent
commit
764d561740
1 changed files with 11 additions and 8 deletions
  1. 11 8
      direct/src/dcparser/dcPacker.cxx

+ 11 - 8
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);
+        }
       }
     }