From 0b8a382c00c6756bd4611e2aa7545d8fe8e82598 Mon Sep 17 00:00:00 2001 From: dweatherford Date: Tue, 25 Mar 2008 03:15:10 +0000 Subject: [PATCH] [thrift] Error checking for T_OBJECT serialization Summary: Avoid segfaulting via calling zend_fetch_class_entry on something that might not actually be an object; throw an exception instead. Reviewed by: shire git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665581 13f79535-47bb-0310-9956-ffa450edef68 --- lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp index 7a402015..86e8921c 100644 --- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp +++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp @@ -681,6 +681,9 @@ void binary_serialize(int8_t thrift_typeID, PHPOutputTransport& transport, zval* return; case T_STRUCT: { TSRMLS_FETCH(); + if (Z_TYPE_PP(value) != IS_OBJECT) { + throw_tprotocolexception("Attempt to send non-object type as a T_STRUCT", INVALID_DATA); + } zval* spec = zend_read_static_property(zend_get_class_entry(*value TSRMLS_CC), "_TSPEC", 6, false TSRMLS_CC); binary_serialize_spec(*value, transport, Z_ARRVAL_P(spec)); } return; -- 2.17.1