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:
authorCampbell Barton <ideasman42@gmail.com>2019-02-21 06:46:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-21 06:49:27 +0300
commita0881a4e9409c5bbc4a9eb2babcaaff03a8b26c7 (patch)
treeacb0351169ddc8799089ee26032b07d0328b0cf0 /source/blender/makesrna/intern/rna_access.c
parentc0659c83a97cb319bf8b47f118495d8f71ae3a90 (diff)
Fix assert w/ multi-dimensional array printing
Own oversight adding assert, result from MEM_allocN_len may be padded.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 0bd6c5352b6..2c365c36b72 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -6316,20 +6316,24 @@ static const char *bool_as_py_string(const int var)
return var ? "True" : "False";
}
-static void *rna_array_as_string_alloc(int type, int len, PointerRNA *ptr, PropertyRNA *prop)
+static void *rna_array_as_string_alloc(
+ int type, int len, PointerRNA *ptr, PropertyRNA *prop, void **r_buf_end)
{
void *buf_ret = NULL;
if (type == PROP_BOOLEAN) {
bool *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__);
RNA_property_boolean_get_array(ptr, prop, buf);
+ *r_buf_end = buf + len;
}
else if (type == PROP_INT) {
int *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__);
RNA_property_int_get_array(ptr, prop, buf);
+ *r_buf_end = buf + len;
}
else if (type == PROP_FLOAT) {
float *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__);
RNA_property_float_get_array(ptr, prop, buf);
+ *r_buf_end = buf + len;
}
else {
BLI_assert(0);
@@ -6391,14 +6395,15 @@ static void rna_array_as_string_recursive(
static void rna_array_as_string(int type, int len, PointerRNA *ptr, PropertyRNA *prop, DynStr *dynstr)
{
- void *buf = rna_array_as_string_alloc(type, len, ptr, prop);
- void *temp_buf = buf;
+ void *buf_end;
+ void *buf = rna_array_as_string_alloc(type, len, ptr, prop, &buf_end);
+ void *buf_step = buf;
int totdim, dim_size[RNA_MAX_ARRAY_DIMENSION];
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
- rna_array_as_string_recursive(type, &temp_buf, totdim, dim_size, dynstr);
- BLI_assert(temp_buf == (char *)buf + MEM_allocN_len(buf));
+ rna_array_as_string_recursive(type, &buf_step, totdim, dim_size, dynstr);
+ BLI_assert(buf_step == buf_end);
MEM_freeN(buf);
}