diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-27 05:39:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-27 05:39:58 +0300 |
commit | 9a8dd37d1aa9d3d67a59ab509fe83402ba8fc964 (patch) | |
tree | 9f3cbbc306b1053f9a4dd3fc19be199ab60d893a /source/blender/makesdna/intern | |
parent | f56bc68231f2ed137ddd260d83b6e25621df9454 (diff) |
makesdna: avoid 'alloca' in a for loop
Issue raised by Sergey in D6634
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 6 |
1 files changed, 5 insertions, 1 deletions
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, |