about summary refs log tree commit homepage
path: root/ext/unicorn_http/unicorn_http.rl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/unicorn_http/unicorn_http.rl')
-rw-r--r--ext/unicorn_http/unicorn_http.rl10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index ee23a52..26cac0f 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -527,6 +527,8 @@ static VALUE HttpParser_headers(VALUE self, VALUE req, VALUE data)
 {
   struct http_parser *hp = data_get(self);
 
+  rb_str_update(data);
+
   http_parser_execute(hp, req, RSTRING_PTR(data), RSTRING_LEN(data));
   VALIDATE_MAX_LENGTH(hp->start.offset, HEADER);
 
@@ -616,8 +618,12 @@ static VALUE HttpParser_has_headers(VALUE self)
 static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data)
 {
   struct http_parser *hp = data_get(self);
-  char *dptr = RSTRING_PTR(data);
-  long dlen = RSTRING_LEN(data);
+  char *dptr;
+  long dlen;
+
+  rb_str_update(data);
+  dptr = RSTRING_PTR(data);
+  dlen = RSTRING_LEN(data);
 
   StringValue(buf);
   rb_str_resize(buf, dlen); /* we can never copy more than dlen bytes */