From 52300ccc877ebfc09396afa15f74500d275df3ca Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 28 Aug 2023 15:17:08 +0200 Subject: [PATCH] Writefile: Add validation of ID names as part of pre-write checks. NOTE: This code remains only executed in 'unlikely' case `G_DEBUG_IO` is enabled. Think this should be systematically done, even though it can have a non-neglectable cost... Will submit design task first though. --- source/blender/blenloader/intern/writefile.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index b617aac8a19..45dba054463 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -95,6 +95,7 @@ #include "BLI_math_base.h" #include "BLI_mempool.h" #include "BLI_threads.h" + #include "MEM_guardedalloc.h" /* MEM_freeN */ #include "BKE_blender_version.h" @@ -107,6 +108,7 @@ #include "BKE_lib_override.hh" #include "BKE_lib_query.h" #include "BKE_main.h" +#include "BKE_main_namemap.h" #include "BKE_node.hh" #include "BKE_packedFile.h" #include "BKE_report.h" @@ -1438,6 +1440,12 @@ bool BLO_write_file(Main *mainvar, BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* save to disk"); BLO_main_validate_libraries(mainvar, reports); BLO_main_validate_shapekeys(mainvar, reports); + if (!BKE_main_namemap_validate_and_fix(mainvar)) { + BKE_report(reports, + RPT_ERROR, + "Critical data corruption: Conflicts and/or otherwise invalid data-blocks names " + "(see console for details)"); + } } /* open temporary file, so we preserve the original in case we crash */