]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
prevent a segfault in case a bsp file has zero nodes (happens on broken input to...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 29 Jan 2011 10:14:13 +0000 (10:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 29 Jan 2011 10:14:13 +0000 (10:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10778 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c

index d41a589110b1754c0baca5fcc55fa516102a3fe4..bbcdffbcc73af03ef9d7bb6900076416ba97c8ec 100644 (file)
@@ -2565,6 +2565,8 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error("Mod_Q1BSP_LoadNodes: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
+       if (count == 0)
+               Host_Error("Mod_Q1BSP_LoadNodes: missing BSP tree in %s",loadmodel->name);
        out = (mnode_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out));
 
        loadmodel->brush.data_nodes = out;
@@ -5499,6 +5501,8 @@ static void Mod_Q3BSP_LoadNodes(lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error("Mod_Q3BSP_LoadNodes: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
+       if (count == 0)
+               Host_Error("Mod_Q3BSP_LoadNodes: missing BSP tree in %s",loadmodel->name);
        out = (mnode_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
 
        loadmodel->brush.data_nodes = out;