Skip to content

Commit

Permalink
WMS: fix nullptr dereference on invalid document (fixes https://bugs.…
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 15, 2024
1 parent 85b624a commit 4da3841
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions autotest/gdrivers/wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,6 @@ def test_wms_cache_path():
ds.GetMetadataItem("CACHE_PATH").replace("\\", "/")
== "./gdalwmscache_b37af3c29458379e6fdf4ed73300f54e/b37af3c29458379e6fdf4ed73300f54e"
)

with pytest.raises(Exception):
gdal.Open("<GDAL_WMS><Service/><Cache/></GDAL_WMS>")
8 changes: 5 additions & 3 deletions frmts/wms/gdalwmscache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ CPLErr GDALWMSCache::Initialize(const char *pszUrl, CPLXMLNode *pConfig)
else
{
m_osCachePath = CPLFormFilename(
pszDir, CPLSPrintf("gdalwmscache_%s", CPLMD5String(pszUrl)),
pszDir,
CPLSPrintf("gdalwmscache_%s",
CPLMD5String(pszUrl ? pszUrl : "")),
nullptr);
}
}
Expand All @@ -305,8 +307,8 @@ CPLErr GDALWMSCache::Initialize(const char *pszUrl, CPLXMLNode *pConfig)
// Separate folder for each unique dataset url
if (CPLTestBool(CPLGetXMLValue(pConfig, "Unique", "True")))
{
m_osCachePath =
CPLFormFilename(m_osCachePath, CPLMD5String(pszUrl), nullptr);
m_osCachePath = CPLFormFilename(
m_osCachePath, CPLMD5String(pszUrl ? pszUrl : ""), nullptr);
}
CPLDebug("WMS", "Using %s for cache", m_osCachePath.c_str());

Expand Down

0 comments on commit 4da3841

Please sign in to comment.