apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: apr_brigade_split_line() may leave zero length bucket in input brigade
Date Mon, 03 Dec 2007 09:26:54 GMT
On Mon, Dec 03, 2007 at 10:08:10AM +0100, Simone wrote:
> I found that apr_brigade_split_line() may leave a zero length Heap
> bucket in bbIn brigade, when such brigade contains exactly a line. I've
> read the source (1.2.10) and I think it happens in apr_bucket_split(),
> given the fact that the point where to split equals original bucket's
> length.

As you say, this isn't a bug; but avoiding the split in that case is 
cheap so might as well be done.

Index: buckets/apr_brigade.c
===================================================================
--- buckets/apr_brigade.c	(revision 597621)
+++ buckets/apr_brigade.c	(working copy)
@@ -304,7 +304,10 @@
         pos = memchr(str, APR_ASCII_LF, len);
         /* We found a match. */
         if (pos != NULL) {
-            apr_bucket_split(e, pos - str + 1);
+            /* Split the bucket if the LF is not the last byte. */
+            if (len != pos - str + 1) {
+                apr_bucket_split(e, pos - str + 1);
+            }
             APR_BUCKET_REMOVE(e);
             APR_BRIGADE_INSERT_TAIL(bbOut, e);
             return APR_SUCCESS;


Mime
View raw message