From 5e10cc4cadb99baa797615734b643d4dca785e8a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 3 Nov 2016 22:47:52 +0900 Subject: [PATCH] nghttpx: Use gc save/restore around downcase method --- src/shrpx_mruby_module_request.cc | 5 +++++ src/shrpx_mruby_module_response.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/shrpx_mruby_module_request.cc b/src/shrpx_mruby_module_request.cc index 2393fbac..39e87b61 100644 --- a/src/shrpx_mruby_module_request.cc +++ b/src/shrpx_mruby_module_request.cc @@ -224,11 +224,16 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) { mrb_raise(mrb, E_RUNTIME_ERROR, "empty key is not allowed"); } + auto ai = mrb_gc_arena_save(mrb); + key = mrb_funcall(mrb, key, "downcase", 0); auto keyref = make_string_ref(balloc, StringRef{RSTRING_PTR(key), static_cast(RSTRING_LEN(key))}); + + mrb_gc_arena_restore(mrb, ai); + auto token = http2::lookup_token(keyref.byte(), keyref.size()); if (repl) { diff --git a/src/shrpx_mruby_module_response.cc b/src/shrpx_mruby_module_response.cc index 83761568..cabbfbdf 100644 --- a/src/shrpx_mruby_module_response.cc +++ b/src/shrpx_mruby_module_response.cc @@ -116,11 +116,16 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) { mrb_raise(mrb, E_RUNTIME_ERROR, "empty key is not allowed"); } + auto ai = mrb_gc_arena_save(mrb); + key = mrb_funcall(mrb, key, "downcase", 0); auto keyref = make_string_ref(balloc, StringRef{RSTRING_PTR(key), static_cast(RSTRING_LEN(key))}); + + mrb_gc_arena_restore(mrb, ai); + auto token = http2::lookup_token(keyref.byte(), keyref.size()); if (repl) {