Skip to content

Commit 583f684

Browse files
committed
Fix the segmentfault issue caused by delete null pointer
Signed-off-by: Liang <xiaoxia.liang@intel.com>
1 parent b2dda8f commit 583f684

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

Library/Raisr.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,20 +1853,22 @@ RNLERRORTYPE RNLDeinit()
18531853
#ifdef ENABLE_RAISR_OPENCL
18541854
if (gAsmType == OpenCL || gAsmType == OpenCLExternal) {
18551855
RaisrOpenCLRelease(&gOpenCLContext);
1856-
delete gPool;
1857-
if (gPasses == 2)
1858-
delete[] gFilterBuffer2;
1859-
delete[] gFilterBuffer;
1860-
delete[] gPGaussian;
1861-
return RNLErrorNone;
1856+
SAFE_DELETE(gPool);
1857+
if (gPasses == 2)
1858+
SAFE_ARR_DELETE(gFilterBuffer2);
1859+
1860+
SAFE_ARR_DELETE(gFilterBuffer);
1861+
SAFE_ARR_DELETE(gPGaussian);
1862+
return RNLErrorNone;
18621863
}
18631864
#endif
18641865

18651866
for (int threadIdx = 0; threadIdx < gThreadCount; threadIdx++)
18661867
{
1867-
ippsFree(gIppCtx.specY[threadIdx]);
1868-
ippsFree(gIppCtx.pbufferY[threadIdx]);
1869-
1868+
if (gIppCtx.specY[threadIdx])
1869+
ippsFree(gIppCtx.specY[threadIdx]);
1870+
if (gIppCtx.pbufferY[threadIdx])
1871+
ippsFree(gIppCtx.pbufferY[threadIdx]);
18701872
for (int i = 0; i < gPasses; i++)
18711873
{
18721874
SAFE_ARR_DELETE(gIppCtx.segZones[i][threadIdx].inYUpscaled);
@@ -1879,8 +1881,11 @@ RNLERRORTYPE RNLDeinit()
18791881

18801882
SAFE_ARR_DELETE(gIppCtx.specY);
18811883
SAFE_ARR_DELETE(gIppCtx.pbufferY);
1882-
ippsFree(gIppCtx.specUV);
1883-
ippsFree(gIppCtx.pbufferUV);
1884+
1885+
if (gIppCtx.specUV)
1886+
ippsFree(gIppCtx.specUV);
1887+
if (gIppCtx.pbufferUV)
1888+
ippsFree(gIppCtx.pbufferUV);
18841889

18851890
if (gPasses == 2)
18861891
{
@@ -1893,7 +1898,8 @@ RNLERRORTYPE RNLDeinit()
18931898
{
18941899
SAFE_ARR_DELETE(gFilterBuffer2);
18951900
}
1896-
SAFE_ARR_DELETE(gIntermediateY->pData);
1901+
if (gIntermediateY)
1902+
SAFE_ARR_DELETE(gIntermediateY->pData);
18971903
SAFE_DELETE(gIntermediateY);
18981904
}
18991905
#ifdef __AVX512FP16__
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)