Browse Source

better assertions

David Rose 16 years ago
parent
commit
fd51c9b27e
1 changed files with 4 additions and 0 deletions
  1. 4 0
      panda/src/express/pointerToArray.I

+ 4 - 0
panda/src/express/pointerToArray.I

@@ -566,6 +566,10 @@ template<class Element>
 INLINE void PointerToArray<Element>::
 INLINE void PointerToArray<Element>::
 set_subdata(size_type n, size_type count, const string &data) {
 set_subdata(size_type n, size_type count, const string &data) {
   nassertv((data.length() % sizeof(Element)) == 0);
   nassertv((data.length() % sizeof(Element)) == 0);
+  nassertv(n <= size() && n + count <= size());
+  nassertd((this->_void_ptr) != NULL) {
+    ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
+  }
   size_type ncount = data.length() / sizeof(Element);
   size_type ncount = data.length() / sizeof(Element);
   if (ncount < count) {
   if (ncount < count) {
     // Reduce the array.
     // Reduce the array.