diff --git a/ogr/ogrsf_frmts/miramon/mm_wrlayr.c b/ogr/ogrsf_frmts/miramon/mm_wrlayr.c index c0d30b761513..51899ba919cf 100644 --- a/ogr/ogrsf_frmts/miramon/mm_wrlayr.c +++ b/ogr/ogrsf_frmts/miramon/mm_wrlayr.c @@ -4409,7 +4409,10 @@ static int MMCreateRecordDBF(struct MiraMonVectLayerInfo *hMiraMonLayer, if (hMiraMonLayer->TopHeader.nElemCount == 0) { if (MMCreateMMDB(hMiraMonLayer, nullptr)) + { + MMDestroyMMDB(hMiraMonLayer); return MM_FATAL_ERROR_WRITING_FEATURES; + } } result = MMAddDBFRecordToMMDB(hMiraMonLayer, hMMFeature);