[thrift] Error checking for T_OBJECT serialization
authordweatherford <dev-null@apache.org>
Tue, 25 Mar 2008 03:15:10 +0000 (03:15 +0000)
committerdweatherford <dev-null@apache.org>
Tue, 25 Mar 2008 03:15:10 +0000 (03:15 +0000)
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

index 7a40201..86e8921 100644 (file)
@@ -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;