From 87df20becb8d919603679486e6b3edff00300c61 Mon Sep 17 00:00:00 2001 From: loadwiki Date: Tue, 5 Jun 2018 12:49:28 +0800 Subject: [PATCH] memory corruption bug fix: line 203 204,when xb0,yb0,O0[y] reaches the max value, sse::LDu sse::STRu will read or write 1 or two 32 bit invalid memory address --- src/gradientMex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gradientMex.cpp b/src/gradientMex.cpp index 98d2882..200fe7f 100755 --- a/src/gradientMex.cpp +++ b/src/gradientMex.cpp @@ -285,7 +285,7 @@ void hog( float *M, float *O, float *H, int h, int w, int binSize, { float *N, *R; const int hb=h/binSize, wb=w/binSize, nb=hb*wb; // compute unnormalized gradient histograms - R = (float*) wrCalloc(wb*hb*nOrients,sizeof(float)); + R = (float*) wrCalloc(wb*hb*nOrients+2,sizeof(float)); gradHist( M, O, R, h, w, binSize, nOrients, softBin, full ); // compute block normalization values N = hogNormMatrix( R, nOrients, hb, wb, binSize ); @@ -301,7 +301,7 @@ void fhog( float *M, float *O, float *H, int h, int w, int binSize, const int hb=h/binSize, wb=w/binSize, nb=hb*wb, nbo=nb*nOrients; float *N, *R1, *R2; int o, x; // compute unnormalized constrast sensitive histograms - R1 = (float*) wrCalloc(wb*hb*nOrients*2,sizeof(float)); + R1 = (float*) wrCalloc(wb*hb*nOrients*2+2,sizeof(float)); gradHist( M, O, R1, h, w, binSize, nOrients*2, softBin, true ); // compute unnormalized contrast insensitive histograms R2 = (float*) wrCalloc(wb*hb*nOrients,sizeof(float));