David Rose 17 lat temu
rodzic
commit
caae0af597

+ 4 - 2
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1891,8 +1891,10 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) {
   }
 
   if (gltex->total_bytecount != total_bytecount) {
-    gl_free(gltex->allocated_buffer);
-    TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
+    if (gltex->allocated_buffer != NULL) {
+      gl_free(gltex->allocated_buffer);
+      TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
+    }
     gltex->allocated_buffer = (void *)gl_malloc(total_bytecount);
     gltex->total_bytecount = total_bytecount;
     TinyTextureContext::get_class_type().inc_memory_usage(TypeHandle::MC_array, total_bytecount);