diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-08-30 22:27:25 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-09-01 11:30:23 -0700 |
commit | a6e410b7f85f22e6adbc55eb9dd3a494ca7200b2 (patch) | |
tree | d92ed989d4bbb7a5764d2bd7d3c9aba69158b7d2 /ext/clogger_ext | |
parent | a6978053b9e9f4eff3e54bda6b4aa0c06f707075 (diff) | |
download | clogger-a6e410b7f85f22e6adbc55eb9dd3a494ca7200b2.tar.gz |
We're not Rack::Lint, but we still need to take steps to avoid segfaulting if we host non-Rack::Lint-compliant applications. This also updates the pure variant to fail on bad applications, too.
Diffstat (limited to 'ext/clogger_ext')
-rw-r--r-- | ext/clogger_ext/clogger.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index 369baf6..19386e5 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -185,7 +185,7 @@ static int str_case_eq(VALUE a, VALUE b) struct response_ops { long nr; VALUE ops; }; /* this can be worse than O(M*N) :<... but C loops are fast ... */ -static VALUE swap_sent_headers(VALUE kv, VALUE memo) +static VALUE swap_sent_headers_unsafe(VALUE kv, VALUE memo) { struct response_ops *tmp = (struct response_ops *)memo; VALUE key = rb_obj_as_string(RARRAY_PTR(kv)[0]); @@ -214,6 +214,15 @@ static VALUE swap_sent_headers(VALUE kv, VALUE memo) return Qnil; } +static VALUE swap_sent_headers(VALUE kv, VALUE memo) +{ + if (TYPE(kv) != T_ARRAY) + rb_raise(rb_eTypeError, "headers not returning pairs"); + if (RARRAY_LEN(kv) < 2) + rb_raise(rb_eTypeError, "headers not returning pairs"); + return swap_sent_headers_unsafe(kv, memo); +} + static VALUE sent_headers_ops(struct clogger *c) { struct response_ops tmp; |