From: Bryan Duxbury Date: Wed, 2 Sep 2009 20:05:07 +0000 (+0000) Subject: THRIFT-569. rb: Segmentation Fault when using BinaryProtocolAccelerated in Ruby X-Git-Tag: 0.2.0~36 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=3647fc62f531f886d92042157b906f455097aa89;p=common%2Fthrift.git THRIFT-569. rb: Segmentation Fault when using BinaryProtocolAccelerated in Ruby This patch checks to make sure that a value is a string before treating it as one. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@810689 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/ext/binary_protocol_accelerated.c b/lib/rb/ext/binary_protocol_accelerated.c index 728a0572..75aa4c60 100644 --- a/lib/rb/ext/binary_protocol_accelerated.c +++ b/lib/rb/ext/binary_protocol_accelerated.c @@ -76,6 +76,9 @@ static void write_i64_direct(VALUE trans, int64_t value) { } static void write_string_direct(VALUE trans, VALUE str) { + if (TYPE(str) != T_STRING) { + rb_raise(rb_eStandardError, "Value should be a string"); + } write_i32_direct(trans, RSTRING_LEN(str)); rb_funcall(trans, write_method_id, 1, str); }