[Bf-blender-cvs] [f4463cd865a] master: RNA: ensure missing calls to RNA_enum_item_end crash in debug mode

Campbell Barton noreply at git.blender.org
Wed Mar 4 13:50:08 CET 2020


Commit: f4463cd865a228088a7c303c74a5a53b061dc260
Author: Campbell Barton
Date:   Wed Mar 4 23:46:33 2020 +1100
Branches: master
https://developer.blender.org/rBf4463cd865a228088a7c303c74a5a53b061dc260

RNA: ensure missing calls to RNA_enum_item_end crash in debug mode

Would have prevented T74227 from slipping through
since it didn't crash on some systems.

===================================================================

M	source/blender/makesrna/intern/rna_define.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 56516c8af4d..aed2c94b493 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -4350,6 +4350,16 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropert
 
   (*items)[tot] = *item;
   *totitem = tot + 1;
+
+  /* Ensure we get crashes on missing calls to 'RNA_enum_item_end', see T74227. */
+#ifdef DEBUG
+  static const EnumPropertyItem item_error = {
+      -1, POINTER_FROM_INT(-1), -1, POINTER_FROM_INT(-1), POINTER_FROM_INT(-1)};
+  if (item != &item_error) {
+    RNA_enum_item_add(items, totitem, &item_error);
+    *totitem -= 1;
+  }
+#endif
 }
 
 void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)



More information about the Bf-blender-cvs mailing list