From 619185bab5029b75943c8e375ab4740f4bbb7e29 Mon Sep 17 00:00:00 2001 From: AbelPau Date: Mon, 30 Sep 2024 15:50:26 +0200 Subject: [PATCH] MiraMonVector Fix issue 5250834764464128 This correction complements the previous one, which contained a minor error. --- ogr/ogrsf_frmts/miramon/mm_wrlayr.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ogr/ogrsf_frmts/miramon/mm_wrlayr.c b/ogr/ogrsf_frmts/miramon/mm_wrlayr.c index 6fc1530b70c0..9dfb25d310c2 100644 --- a/ogr/ogrsf_frmts/miramon/mm_wrlayr.c +++ b/ogr/ogrsf_frmts/miramon/mm_wrlayr.c @@ -6255,11 +6255,6 @@ 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) @@ -6267,6 +6262,12 @@ int MMCreateMMDB(struct MiraMonVectLayerInfo *hMiraMonLayer, 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); @@ -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); @@ -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);