Serious bugfix for compositing; using Groups could crash if one of the

input nodes was 'passing on' the buffer (because it didn't operate on the
image). That's for example for Blur with size 0 or for Translate node.
This passed-on buffer then got freed inside the group...

Solution now is just a malloc. Better system should be devised, with
reference counting or so. Thanks Ivan Hoffmann for the sample file!
This commit is contained in:
Ton Roosendaal 2006-10-27 19:52:41 +00:00
parent 76ff13de42
commit a7d3a58ba9

@ -124,6 +124,7 @@ static CompBuf *dupalloc_compbuf(CompBuf *cbuf)
return dupbuf; return dupbuf;
} }
#if 0
static CompBuf *pass_on_compbuf(CompBuf *cbuf) static CompBuf *pass_on_compbuf(CompBuf *cbuf)
{ {
CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 0); CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 0);
@ -137,6 +138,7 @@ static CompBuf *pass_on_compbuf(CompBuf *cbuf)
return dupbuf; return dupbuf;
} }
#endif
void free_compbuf(CompBuf *cbuf) void free_compbuf(CompBuf *cbuf)
{ {
@ -2829,8 +2831,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
else { else {
if(in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */ if(in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */
/* pass on image */ /* was pass_on image */
new= pass_on_compbuf(img); new= dupalloc_compbuf(img);
} }
else { else {
NodeBlurData *nbd= node->storage; NodeBlurData *nbd= node->storage;
@ -2956,12 +2958,11 @@ static void node_composit_exec_translate(void *data, bNode *node, bNodeStack **i
{ {
if(in[0]->data) { if(in[0]->data) {
CompBuf *cbuf= in[0]->data; CompBuf *cbuf= in[0]->data;
CompBuf *stackbuf= pass_on_compbuf(cbuf); // no alloc CompBuf *stackbuf= dupalloc_compbuf(cbuf); // no alloc, was pass_on
stackbuf->xof= (int)floor(in[1]->vec[0]); stackbuf->xof= (int)floor(in[1]->vec[0]);
stackbuf->yof= (int)floor(in[2]->vec[0]); stackbuf->yof= (int)floor(in[2]->vec[0]);
stackbuf->rect= cbuf->rect;
out[0]->data= stackbuf; out[0]->data= stackbuf;
} }
} }