From 3647fc62f531f886d92042157b906f455097aa89 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Wed, 2 Sep 2009 20:05:07 +0000 Subject: [PATCH] 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 --- lib/rb/ext/binary_protocol_accelerated.c | 3 +++ 1 file changed, 3 insertions(+) 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); } -- 2.17.1