openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

Small memory leak in unittest

Open ethanhugg opened this issue 12 years ago • 1 comments

Was running the codec_unittest under valgrind checking for leaks and it looked pretty good. It found this one though in the unittest code.

You will see that pPred and pRef are allocated at the top of this function but only pRef is deleted at the end. From EncUT_GetIntraPredictor.cpp:

TEST(GetIntraPredictorTest, TestGetI16x16LumaPredPlane) { const int32_t kiStride = rand()%16+16;

int32_t i, j;

uint8_t _pPred = new uint8_t[16_kiStride]; uint8_t _pRef = new uint8_t[16_kiStride+1]; for (i=0; i<16*kiStride+1; i++) pRef[i]=rand()%256+1;

pRef += kiStride + 1;

int32_t iA=0, iB=0, iC=0, iH=0, iV=0; uint8_t *pTop = &pRef[-kiStride]; uint8_t *pLeft = &pRef[-1]; int32_t iPredStride = 16;

for (i=0; i<8; i++) { iH += (i + 1) * (pTop[8 + i] - pTop[6 - i]); iV += (i + 1) * (pLeft[(8 + i)_kiStride] - pLeft[(6 - i)_kiStride]); }

iA = (pLeft[15*kiStride] + pTop[15]) << 4; iB = (5 * iH + 32) >> 6; iC = (5 * iV + 32) >> 6;

WelsI16x16LumaPredPlane_c(pPred, pRef, kiStride); for (i=0; i<16; i++) { for (j=0; j<16; j++) { EXPECT_EQ(pPred[j],(uint8_t)WelsClip1((iA + iB * (j - 7) + iC * (i - 7) + 16) >> 5)); } pPred += iPredStride; }

pRef -= kiStride + 1; delete []pRef; }

ethanhugg avatar Jun 10 '14 00:06 ethanhugg

Fixed now. Thanks.

ethanhugg avatar Jun 10 '14 02:06 ethanhugg