Browse Source

better fix for crash

David Rose 20 years ago
parent
commit
effdbb24af
1 changed files with 10 additions and 2 deletions
  1. 10 2
      direct/src/dcparser/dcPacker.cxx

+ 10 - 2
direct/src/dcparser/dcPacker.cxx

@@ -863,10 +863,17 @@ unpack_object() {
           // valid constructor, create the class object instead of
           // valid constructor, create the class object instead of
           // just a tuple.
           // just a tuple.
           object = unpack_class_object(dclass);
           object = unpack_class_object(dclass);
-          break;
+          if (object == (PyObject *)NULL) {
+            cerr << "Unable to construct object of class "
+                 << dclass->get_name() << "\n";
+          } else {
+            break;
+          }
         }
         }
       }
       }
     }
     }
+    // Fall through (if no constructor)
+
     // If we don't know what kind of class object it is, or it doesn't
     // If we don't know what kind of class object it is, or it doesn't
     // have a constructor, fall through and make a tuple.
     // have a constructor, fall through and make a tuple.
   default:
   default:
@@ -878,7 +885,7 @@ unpack_object() {
       while (more_nested_fields()) {
       while (more_nested_fields()) {
         PyObject *element = unpack_object();
         PyObject *element = unpack_object();
         PyList_Append(object, element);
         PyList_Append(object, element);
-        Py_XDECREF(element);
+        Py_DECREF(element);
       }
       }
       pop();
       pop();
 
 
@@ -893,6 +900,7 @@ unpack_object() {
     break;
     break;
   }
   }
 
 
+  nassertr(object != (PyObject *)NULL, Py_None);
   return object;
   return object;
 }
 }
 #endif  // HAVE_PYTHON
 #endif  // HAVE_PYTHON