Skip to content

Commit f8c8b71

Browse files
committed
NWT_GRD: avoid cppcheck false positive about memleak
1 parent 1d8b208 commit f8c8b71

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

frmts/northwood/grddataset.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,8 @@ GDALDataset *NWT_GRDDataset::Create(const char *pszFilename, int nXSize,
10561056
if (poDS->fp == nullptr)
10571057
{
10581058
CPLError(CE_Failure, CPLE_FileIO, "Failed to create GRD file");
1059+
nwtCloseGrid(poDS->pGrd);
1060+
poDS->pGrd = nullptr;
10591061
delete poDS;
10601062
return nullptr;
10611063
}
@@ -1070,6 +1072,9 @@ GDALDataset *NWT_GRDDataset::Create(const char *pszFilename, int nXSize,
10701072
if (poDS->UpdateHeader() != 0)
10711073
{
10721074
CPLError(CE_Failure, CPLE_FileIO, "Failed to create GRD file");
1075+
poDS->pGrd->fp = nullptr;
1076+
nwtCloseGrid(poDS->pGrd);
1077+
poDS->pGrd = nullptr;
10731078
delete poDS;
10741079
return nullptr;
10751080
}

0 commit comments

Comments
 (0)