diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-12 21:17:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-12 21:18:50 +0400 |
commit | d7824e435f52f82a9e54c79e8fab5364a9ca39c9 (patch) | |
tree | 196bc3e8862b97e1945724562d878f5e404e13db /source/blender/makesrna | |
parent | 4fa93b1ea44608f0bf135c6f4b98ba42d7e5dacc (diff) |
Fix possible (unlikely) use of uninitialized pointer in RNA resolving
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 51e01d93799..10ad05c37c5 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3875,7 +3875,7 @@ static int rna_token_strip_quotes(char *token) static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_nextptr) { - char fixedbuf[256], *token; + char fixedbuf[256]; int intkey; *r_nextptr = *ptr; @@ -3885,6 +3885,8 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr return true; if (**path == '[') { + char *token; + /* resolve the lookup with [] brackets */ token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1); @@ -3933,7 +3935,7 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, PropertyRNA *prop, int *r_index) { - char fixedbuf[256], *token; + char fixedbuf[256]; int index_arr[RNA_MAX_ARRAY_DIMENSION] = {0}; int len[RNA_MAX_ARRAY_DIMENSION]; const int dim = RNA_property_array_dimension(ptr, prop, len); @@ -3947,6 +3949,7 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope for (i = 0; i < dim; i++) { int temp_index = -1; + char *token; /* multi index resolve */ if (**path == '[') { @@ -3982,6 +3985,10 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope } temp_index = RNA_property_array_item_index(prop, *token); } + else { + /* just to avoid uninitialized pointer use */ + token = fixedbuf; + } if (token != fixedbuf) { MEM_freeN(token); @@ -4020,7 +4027,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, { PropertyRNA *prop; PointerRNA curptr; - char fixedbuf[256], *token; + char fixedbuf[256]; int type; prop = NULL; @@ -4031,6 +4038,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, while (*path) { int use_id_prop = (*path == '[') ? 1 : 0; + char *token; /* custom property lookup ? * C.object["someprop"] */ @@ -4222,7 +4230,7 @@ char *RNA_path_back(const char *path) { char fixedbuf[256]; const char *previous, *current; - char *result, *token; + char *result; int i; if (!path) @@ -4234,6 +4242,8 @@ char *RNA_path_back(const char *path) /* parse token by token until the end, then we back up to the previous * position and strip of the next token to get the path one step back */ while (*current) { + char *token; + token = rna_path_token(¤t, fixedbuf, sizeof(fixedbuf), 0); if (!token) |