[Bf-blender-cvs] [9a8dd37d1aa] blender-v2.82-release: makesdna: avoid 'alloca' in a for loop
Campbell Barton
noreply at git.blender.org
Mon Jan 27 03:41:23 CET 2020
Commit: 9a8dd37d1aa9d3d67a59ab509fe83402ba8fc964
Author: Campbell Barton
Date: Mon Jan 27 13:39:58 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rB9a8dd37d1aa9d3d67a59ab509fe83402ba8fc964
makesdna: avoid 'alloca' in a for loop
Issue raised by Sergey in D6634
===================================================================
M source/blender/makesdna/intern/makesdna.c
===================================================================
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index dc32ca7e244..6b4b4854515 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -942,7 +942,11 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char
/* Write size verification to file. */
{
- char *name_static = alloca(namelen + 1);
+ /* Normally 'alloca' would be used here, however we can't in a loop.
+ * Use an over-sized buffer instead. */
+ char name_static[1024];
+ BLI_assert(sizeof(name_static) > namelen);
+
DNA_elem_id_strip_copy(name_static, cp);
const char *str_pair[2] = {types[structtype], name_static};
const char *name_alias = BLI_ghash_lookup(g_version_data.elem_map_alias_from_static,
More information about the Bf-blender-cvs
mailing list