On Thu, Aug 27, 2009 at 08:37:46PM +0100, Stefan Sperling wrote:
> On Thu, Aug 27, 2009 at 09:24:53PM +0200, Daniel Näslund wrote:
> > if (filtered)
> > *stringbuf = svn_stringbuf_create_ensure(0, pool);
> > + else if (stream->line_transformer_cb)
> > + SVN_ERR(line_transformer(stream, stringbuf, str->data,
> > + iterpool));
>
> Passing iterpool here can cause problems, since the result will go
> to the caller.
Same problem further down the function:
> @@ -268,6 +295,9 @@
> while (filtered);
> *stringbuf = svn_stringbuf_dup(str, pool);
>
> + if (stream->line_transformer_cb)
> + SVN_ERR(line_transformer(stream, stringbuf, str->data, iterpool));
> +
> svn_pool_destroy(iterpool);
> return SVN_NO_ERROR;
> }
That won't work. Making a habit of creating iterpools just before the
loop is entered, and destroying then right after the loop is exited
can help to avoid such problems. (Note how the existing code got this
wrong.)
Also, we should not create a stringbuf here we don't use if the
transformer is active, so I've changed this to:
}
while (filtered);
svn_pool_destroy(iterpool);
if (stream->line_transformer_cb)
SVN_ERR(line_transformer(stream, stringbuf, str->data, pool));
else
*stringbuf = svn_stringbuf_dup(str, pool);
return SVN_NO_ERROR;
Stefan
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2387997
Received on 2009-08-27 21:50:01 CEST