From 3f7c057f9207fed87ffff41123c745cd8846d132 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 26 Dec 2016 10:39:03 +0100 Subject: [PATCH] - Fixed heap use after free issue with lights. --- src/gl/dynlights/a_dynlight.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 4ba95af87..114633b3f 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -599,7 +599,6 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe for (unsigned i = 0; i < collected_ss.Size(); i++) { subSec = collected_ss[i].sub; - auto &pos = collected_ss[i].pos; touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) @@ -608,9 +607,10 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe subSec->sector->validcount = ::validcount; } - for (unsigned int i = 0; i < subSec->numlines; i++) + for (unsigned int j = 0; j < subSec->numlines; ++j) { - seg_t * seg = subSec->firstline + i; + auto &pos = collected_ss[i].pos; + seg_t *seg = subSec->firstline + j; // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) // If out of range we do not need to bother with this seg.