Skip to content

Commit

Permalink
GDALVectorTranslate(): fix null-ptr dereference when no source driver
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Nov 17, 2024
1 parent dd6f82c commit 9b5cc40
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4907,9 +4907,11 @@ SetupTargetLayer::Setup(OGRLayer *poSrcLayer, const char *pszNewLayerName,
std::map<int, TargetLayerInfo::ResolvedInfo> oMapResolved;

/* Determine if NUMERIC field width narrowing is allowed */
auto poSrcDriver = m_poSrcDS->GetDriver();
const char *pszSrcWidthIncludesDecimalSeparator{
m_poSrcDS->GetDriver()->GetMetadataItem(
"DMD_NUMERIC_FIELD_WIDTH_INCLUDES_DECIMAL_SEPARATOR")};
poSrcDriver ? poSrcDriver->GetMetadataItem(
"DMD_NUMERIC_FIELD_WIDTH_INCLUDES_DECIMAL_SEPARATOR")
: nullptr};
const bool bSrcWidthIncludesDecimalSeparator{
pszSrcWidthIncludesDecimalSeparator &&
EQUAL(pszSrcWidthIncludesDecimalSeparator, "YES")};
Expand All @@ -4920,8 +4922,9 @@ SetupTargetLayer::Setup(OGRLayer *poSrcLayer, const char *pszNewLayerName,
pszDstWidthIncludesDecimalSeparator &&
EQUAL(pszDstWidthIncludesDecimalSeparator, "YES")};
const char *pszSrcWidthIncludesMinusSign{
m_poSrcDS->GetDriver()->GetMetadataItem(
"DMD_NUMERIC_FIELD_WIDTH_INCLUDES_SIGN")};
poSrcDriver ? poSrcDriver->GetMetadataItem(
"DMD_NUMERIC_FIELD_WIDTH_INCLUDES_SIGN")
: nullptr};
const bool bSrcWidthIncludesMinusSign{
pszSrcWidthIncludesMinusSign &&
EQUAL(pszSrcWidthIncludesMinusSign, "YES")};
Expand Down

0 comments on commit 9b5cc40

Please sign in to comment.