From 5e3093c90aec7351f328c2fca255c9e5ee774f2a Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 29 Jan 2011 10:14:13 +0000 Subject: [PATCH] prevent a segfault in case a bsp file has zero nodes (happens on broken input to q3map2) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10778 d7cf8633-e32d-0410-b094-e92efae38249 --- model_brush.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/model_brush.c b/model_brush.c index d41a5891..bbcdffbc 100644 --- a/model_brush.c +++ b/model_brush.c @@ -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; -- 2.39.2