Skip to content

Commit

Permalink
Merge pull request #11783 from AbelPau/MiraMonVector-Fix-Issue-393742177
Browse files Browse the repository at this point in the history
MiraMonVector: Fix issue 393742177 oss-fuzz
  • Loading branch information
rouault authored Feb 3, 2025
2 parents f82e760 + 6ccef05 commit d890cbc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ogr/ogrsf_frmts/miramon/mm_wrlayr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3729,6 +3729,7 @@ static int MMCreateFeaturePolOrArc(struct MiraMonVectLayerInfo *hMiraMonLayer,
MM_N_VERTICES_TYPE nPolVertices = 0;
MM_BOOLEAN bReverseArc;
int prevCoord = -1;
MM_BOOLEAN bPolZeroJustCreated = FALSE;

if (!hMiraMonLayer)
return MM_FATAL_ERROR_WRITING_FEATURES;
Expand Down Expand Up @@ -3824,7 +3825,16 @@ static int MMCreateFeaturePolOrArc(struct MiraMonVectLayerInfo *hMiraMonLayer,

// Universal polygon have a record with ID_GRAFIC=0 and blancs
if (MMAddPolygonRecordToMMDB(hMiraMonLayer, nullptr, 0, 0, nullptr))
{
// Rare case where polygon zero creates the database
// but some error occurs in the creation of the polygon zero.
// The database must be destroyed and created again
// next time the polygon zero is created.
MMCloseMMBD_XP(hMiraMonLayer);
MMDestroyMMDB(hMiraMonLayer);
return MM_FATAL_ERROR_WRITING_FEATURES;
}
bPolZeroJustCreated = TRUE;
}
}

Expand Down Expand Up @@ -3967,7 +3977,18 @@ static int MMCreateFeaturePolOrArc(struct MiraMonVectLayerInfo *hMiraMonLayer,
pCoord = hMMFeature->pCoord;

if (!pCoord)
{
if (bPolZeroJustCreated)
{
// Rare case where polygon zero creates the database
// but some error occurs in the creation of the polygon zero.
// The database must be destroyed and created again
// next time the polygon zero is created.
MMCloseMMBD_XP(hMiraMonLayer);
MMDestroyMMDB(hMiraMonLayer);
}
return MM_FATAL_ERROR_WRITING_FEATURES;
}

// Doing real job
for (nIPart = 0; nIPart < hMMFeature->nNRings; nIPart++,
Expand Down

0 comments on commit d890cbc

Please sign in to comment.