Skip to content

Commit

Permalink
PDF: fix nullptr dereference on invalid file
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Oct 29, 2024
1 parent b4a3fde commit 2ed74d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Binary file added autotest/gdrivers/data/pdf/invalid_srs.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions autotest/gdrivers/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3345,3 +3345,14 @@ def test_pdf_iso32000_esri_as_epsg():
assert sr.GetAuthorityName(None) == "ESRI"
assert sr.GetAuthorityCode(None) == "102422"
assert gdal.GetLastErrorMsg() == ""


###############################################################################
# Test bugfix for https://issues.oss-fuzz.com/issues/376126833


@pytest.mark.skipif(not have_read_support(), reason="no read support available")
def test_pdf_iso32000_invalid_srs():

# Just test that this does not crash
gdal.Open("data/pdf/invalid_srs.pdf")
5 changes: 3 additions & 2 deletions frmts/pdf/pdfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7074,8 +7074,9 @@ int PDFDataset::ParseMeasure(GDALPDFObject *poMeasure, double dfMediaBoxWidth,
// Check consistency of ESRI:xxxx and WKT definitions
if (poGCSWKT != nullptr)
{
if (!EQUAL(oSRS_ESRI.GetName(), m_oSRS.GetName()) &&
!oSRS_ESRI.IsSame(&m_oSRS))
if (!m_oSRS.GetName() ||
(!EQUAL(oSRS_ESRI.GetName(), m_oSRS.GetName()) &&
!oSRS_ESRI.IsSame(&m_oSRS)))
{
CPLDebug("PDF",
"Definition from ESRI:%d and WKT=%s do not "
Expand Down

0 comments on commit 2ed74d7

Please sign in to comment.