From 7b341e1b55d963a2ff9dea802f2f14932eccf2d9 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 18 Feb 2018 16:06:56 -0700 Subject: [PATCH] BSPX_AddLump: copy the input data --- common/bspfile.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/bspfile.cc b/common/bspfile.cc index c8f00edc..6cbfd019 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -2222,7 +2222,11 @@ void BSPX_AddLump(bspdata_t *bspdata, const char *xname, const void *xdata, size bspdata->bspxentries = e; } - e->lumpdata = xdata; + //ericw -- make a copy + byte *xdata_copy = (byte*) malloc(xsize); + memcpy(xdata_copy, xdata, xsize); + + e->lumpdata = xdata_copy; e->lumpsize = xsize; } const void *BSPX_GetLump(bspdata_t *bspdata, const char *xname, size_t *xsize)