THRIFT-569. rb: Segmentation Fault when using BinaryProtocolAccelerated in Ruby
authorBryan Duxbury <bryanduxbury@apache.org>
Wed, 2 Sep 2009 20:05:07 +0000 (20:05 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Wed, 2 Sep 2009 20:05:07 +0000 (20:05 +0000)
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

index 728a057..75aa4c6 100644 (file)
@@ -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);
 }