Skip to content

Commit 7967a18

Browse files
committed
GDALDeserializeGCPListFromXML(): fix memleak in error code path (master only, fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66620)
1 parent 0c14536 commit 7967a18

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

gcore/gdal_misc.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -4224,14 +4224,15 @@ void GDALDeserializeGCPListFromXML(CPLXMLNode *psGCPList,
42244224
return true;
42254225
};
42264226

4227+
bool bOK = true;
42274228
if (!ParseDoubleValue("Pixel", psGCP->dfGCPPixel))
4228-
continue;
4229+
bOK = false;
42294230
if (!ParseDoubleValue("Line", psGCP->dfGCPLine))
4230-
continue;
4231+
bOK = false;
42314232
if (!ParseDoubleValue("X", psGCP->dfGCPX))
4232-
continue;
4233+
bOK = false;
42334234
if (!ParseDoubleValue("Y", psGCP->dfGCPY))
4234-
continue;
4235+
bOK = false;
42354236
const char *pszZ = CPLGetXMLValue(psXMLGCP, "Z", nullptr);
42364237
if (pszZ == nullptr)
42374238
{
@@ -4245,10 +4246,17 @@ void GDALDeserializeGCPListFromXML(CPLXMLNode *psGCPList,
42454246
{
42464247
CPLError(CE_Failure, CPLE_AppDefined,
42474248
"GCP#Z=%s is an invalid value", pszZ);
4248-
continue;
4249+
bOK = false;
42494250
}
42504251

4251-
(*pnGCPCount)++;
4252+
if (!bOK)
4253+
{
4254+
GDALDeinitGCPs(1, psGCP);
4255+
}
4256+
else
4257+
{
4258+
(*pnGCPCount)++;
4259+
}
42524260
}
42534261
}
42544262

0 commit comments

Comments
 (0)