Skip to content

Commit

Permalink
MiraMonVector Fix issue 5250834764464128
Browse files Browse the repository at this point in the history
This correction complements the previous one, which contained a minor error.
  • Loading branch information
AbelPau committed Sep 30, 2024
1 parent d04e73d commit 619185b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions ogr/ogrsf_frmts/miramon/mm_wrlayr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6255,18 +6255,19 @@ int MMCreateMMDB(struct MiraMonVectLayerInfo *hMiraMonLayer,
hMiraMonLayer->nSRSType = MM_SRS_LAYER_IS_GEOGRAPHIC_TYPE;
}

// Before allocating new memory, there might be some previously allocated but unused memory.
// Let's free that memory first.
if (hMiraMonLayer->MMArc.MMAdmDB.pMMBDXP)
MM_ReleaseDBFHeader(&hMiraMonLayer->MMArc.MMAdmDB.pMMBDXP);

if (hMiraMonLayer->bIsPoint)
{
if (hMiraMonLayer->pLayerDB)
nNFields =
MM_PRIVATE_POINT_DB_FIELDS + hMiraMonLayer->pLayerDB->nNFields;
else
nNFields = MM_PRIVATE_POINT_DB_FIELDS;

// Before allocating new memory, there might be some previously allocated but unused memory.
// Let's free that memory first.
if (hMiraMonLayer->MMPoint.MMAdmDB.pMMBDXP)
MM_ReleaseDBFHeader(&hMiraMonLayer->MMPoint.MMAdmDB.pMMBDXP);

pBD_XP = hMiraMonLayer->MMPoint.MMAdmDB.pMMBDXP =
MM_CreateDBFHeader(nNFields, hMiraMonLayer->nCharSet);

Expand All @@ -6285,6 +6286,11 @@ int MMCreateMMDB(struct MiraMonVectLayerInfo *hMiraMonLayer,
else
nNFields = MM_PRIVATE_ARC_DB_FIELDS;

// Before allocating new memory, there might be some previously allocated but unused memory.
// Let's free that memory first.
if (hMiraMonLayer->MMArc.MMAdmDB.pMMBDXP)
MM_ReleaseDBFHeader(&hMiraMonLayer->MMArc.MMAdmDB.pMMBDXP);

pBD_XP = hMiraMonLayer->MMArc.MMAdmDB.pMMBDXP =
MM_CreateDBFHeader(nNFields, hMiraMonLayer->nCharSet);

Expand Down Expand Up @@ -6320,6 +6326,11 @@ int MMCreateMMDB(struct MiraMonVectLayerInfo *hMiraMonLayer,
else
nNFields = MM_PRIVATE_POLYGON_DB_FIELDS;

// Before allocating new memory, there might be some previously allocated but unused memory.
// Let's free that memory first.
if (hMiraMonLayer->MMPolygon.MMAdmDB.pMMBDXP)
MM_ReleaseDBFHeader(&hMiraMonLayer->MMPolygon.MMAdmDB.pMMBDXP);

pBD_XP = hMiraMonLayer->MMPolygon.MMAdmDB.pMMBDXP =
MM_CreateDBFHeader(nNFields, hMiraMonLayer->nCharSet);

Expand Down

0 comments on commit 619185b

Please sign in to comment.