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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-07-20 17:20:48 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-07-20 17:25:01 +0300
commit9ee1f96a0fa603e223fb34a480d2fdcb254bf514 (patch)
tree9ae8fa80447223f9c84778667e3e627005ad832a /source/blender/blenkernel
parent40d4da829cb234c013e857aee4e85902799c87f5 (diff)
Fix (unreported) potential serious bug in CustomData_merge().
It was always only using the flags from the first source layer of a given type, not from the layer actually being handled. This was (probably) more or less harmless for the CD_FLAG_NOCOPY test, but could be really bad when checking CD_FLAG_NOFREE, and when copying the flags over to new copied data!
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/customdata.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index bdc128915a5..82465172892 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1441,7 +1441,7 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
/*const LayerTypeInfo *typeInfo;*/
CustomDataLayer *layer, *newlayer;
void *data;
- int i, type, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0;
+ int i, type, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, flag = 0;
int number = 0, maxnumber = -1;
bool changed = false;
@@ -1450,6 +1450,7 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
/*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/
type = layer->type;
+ flag = layer->flag;
if (type != lasttype) {
number = 0;
@@ -1459,12 +1460,11 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
lastclone = layer->active_clone;
lastmask = layer->active_mask;
lasttype = type;
- lastflag = layer->flag;
}
else
number++;
- if (lastflag & CD_FLAG_NOCOPY) continue;
+ if (flag & CD_FLAG_NOCOPY) continue;
else if (!(mask & CD_TYPE_AS_MASK(type))) continue;
else if ((maxnumber != -1) && (number >= maxnumber)) continue;
else if (CustomData_get_layer_named(dest, type, layer->name)) continue;
@@ -1480,12 +1480,12 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
break;
}
- if ((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE))
- newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE,
- data, totelem, layer->name);
- else
- newlayer = customData_add_layer__internal(dest, type, alloctype,
- data, totelem, layer->name);
+ if ((alloctype == CD_ASSIGN) && (flag & CD_FLAG_NOFREE)) {
+ newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE, data, totelem, layer->name);
+ }
+ else {
+ newlayer = customData_add_layer__internal(dest, type, alloctype, data, totelem, layer->name);
+ }
if (newlayer) {
newlayer->uid = layer->uid;
@@ -1494,7 +1494,7 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
newlayer->active_rnd = lastrender;
newlayer->active_clone = lastclone;
newlayer->active_mask = lastmask;
- newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
+ newlayer->flag |= flag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
changed = true;
}
}