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 728a057..75aa4c6 100644
--- a/lib/rb/ext/binary_protocol_accelerated.c
+++ b/lib/rb/ext/binary_protocol_accelerated.c
@@ -76,6 +76,9 @@
}
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);
}