THRIFT-547. rb: Thrift deserializer hangs when deserializing empty string
Thrift::MemoryBuffer will now throw an EOFError when it cannot fulfill a request for data.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@799696 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/ext/memory_buffer.c b/lib/rb/ext/memory_buffer.c
index 624012d..3a9c101 100644
--- a/lib/rb/ext/memory_buffer.c
+++ b/lib/rb/ext/memory_buffer.c
@@ -54,6 +54,10 @@
index = 0;
}
+ if (RSTRING(data)->len < length) {
+ rb_raise(rb_eEOFError, "Not enough bytes remain in memory buffer");
+ }
+
rb_ivar_set(self, index_ivar_id, INT2FIX(index));
return data;
}