Skip to content

Commit 7b610c0

Browse files
committed
DXF: avoid memleak in error code path
1 parent f221eba commit 7b610c0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ogr/ogrsf_frmts/dxf/ogrdxfdatasource.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,8 @@ OGRDXFDataSource::GetEntryFromAcDsDataSection(const char *pszEntityHandle,
11151115
while (ReadValue(szLineBuf, sizeof(szLineBuf)) == 310)
11161116
{
11171117
int nBytesRead;
1118-
GByte *pabyHex = CPLHexToBinary(szLineBuf, &nBytesRead);
1118+
std::unique_ptr<GByte, VSIFreeReleaser> pabyHex(
1119+
CPLHexToBinary(szLineBuf, &nBytesRead));
11191120

11201121
if (nPos + nBytesRead > nLen)
11211122
{
@@ -1127,12 +1128,10 @@ OGRDXFDataSource::GetEntryFromAcDsDataSection(const char *pszEntityHandle,
11271128
}
11281129
else
11291130
{
1130-
std::copy_n(pabyHex, nBytesRead,
1131+
std::copy_n(pabyHex.get(), nBytesRead,
11311132
oSolidBinaryData[osThisHandle].begin() + nPos);
11321133
nPos += nBytesRead;
11331134
}
1134-
1135-
CPLFree(pabyHex);
11361135
}
11371136
}
11381137
}

0 commit comments

Comments
 (0)