Browse Source

checks size of surface table when adding a surface entry

John Loehrlein 18 years ago
parent
commit
2e8c0c17cc
1 changed files with 6 additions and 0 deletions
  1. 6 0
      panda/src/ode/odeWorld.cxx

+ 6 - 0
panda/src/ode/odeWorld.cxx

@@ -78,6 +78,12 @@ init_surface_table(PN_uint8 num_surfaces)
 void OdeWorld::
 void OdeWorld::
 set_surface(int pos1, int pos2, sSurfaceParams& entry)
 set_surface(int pos1, int pos2, sSurfaceParams& entry)
 {
 {
+    odeworld_cat.debug() << " pos1 " << pos1 << " pos2 " << pos2 << " num surfaces " << (int)_num_surfaces << " endline\n";
+    if((_num_surfaces <= pos1) || (_num_surfaces <= pos2))
+    {
+        odeworld_cat.error() << "surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." << "\n";
+        return;
+    }
     int true_pos = (pos1 * _num_surfaces) + pos2;
     int true_pos = (pos1 * _num_surfaces) + pos2;
     _surface_table[true_pos].colparams.mode = entry.colparams.mode;
     _surface_table[true_pos].colparams.mode = entry.colparams.mode;
     _surface_table[true_pos].colparams.mu = entry.colparams.mu;
     _surface_table[true_pos].colparams.mu = entry.colparams.mu;