From d2909cd4dd481554f373016c7a6b94f01ea39b44 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 30 Dec 2012 20:51:13 +0900 Subject: [PATCH] Clear the padding in the light data buffers. Getting uninitialized memory in calloced space was interesting :P --- tools/qflight/source/qflight.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/qflight/source/qflight.c b/tools/qflight/source/qflight.c index c13a18ff1..62eda9af1 100644 --- a/tools/qflight/source/qflight.c +++ b/tools/qflight/source/qflight.c @@ -84,16 +84,22 @@ float minlights[MAX_MAP_FACES]; int GetFileSpace (int size) { + int oldsize; int ofs; LOCK; + oldsize = lightdata->size; lightdata->size = (lightdata->size + 3) & ~3; ofs = lightdata->size; lightdata->size += size; dstring_adjust (lightdata); + memset (lightdata->str + oldsize, 0, ofs - oldsize); + memset (lightdata->str + ofs, 0, size); rgblightdata->size = (ofs + size) * 3; dstring_adjust (rgblightdata); + memset (rgblightdata->str + oldsize * 3, 0, (ofs - oldsize) * 3); + memset (rgblightdata->str + ofs * 3, 0, size * 3); UNLOCK; return ofs; }