Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-06-22 20:02:52 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-06-23 20:22:50 +0300
commitdc64673f6e096408f5bf5ba646512aebac4e0a59 (patch)
treeeab2f9afc7e5479095871bbaf4afcf8ff71aba3c /source/blender/makesrna/intern/rna_define.c
parent56435b3268bceaf24c13336976c84a91a33f9283 (diff)
Fix T97691: undefined behavior sanitizer warning for alignment in RNA functions
Thanks Loren Osborn for investigating this and proposing solutions. Ref D14798
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r--source/blender/makesrna/intern/rna_define.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 9d26797aa88..a747a5d11d8 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -4421,6 +4421,16 @@ int rna_parameter_size(PropertyRNA *parm)
return sizeof(void *);
}
+int rna_parameter_size_pad(const int size)
+{
+ /* Pad parameters in memory so the next parameter is properly aligned.
+ * This silences warnings in ubsan. More complicated logic to pack parameters
+ * more tightly in memory is unlikely to improve performance, and aligning
+ * to the requirements for pointers is enough for all data types we use. */
+ const int alignment = sizeof(void *);
+ return (size + alignment - 1) & ~(alignment - 1);
+}
+
/* Dynamic Enums */
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)