From 79bba4abefb57f12b54ddd338ed8f9ec828b5e89 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 18 Aug 2009 23:28:31 -0700 Subject: http: make strings independent before modification Ruby strings may be copy-on-write (multiple #dup'ed strings can point to the same internal buffers). So since HttpParser#headers modifies its buffer argument, we'll need to make sure the String object we have points to its own private buffer. This doesn't affect Unicorn except in a to-be-written test case that relies on a #dup'ed String. --- ext/unicorn_http/unicorn_http.rl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 19091f4..ed9c359 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -383,6 +383,8 @@ static void advance_str(VALUE str, off_t nr) if (len == 0) return; + rb_str_modify(str); + assert(nr <= len); len -= nr; if (len > 0) /* unlikely, len is usually 0 */ -- cgit v1.2.3-24-ge0c7