Author: bryanduxbury
Date: Tue May 12 16:53:23 2009
New Revision: 773976

URL: http://svn.apache.org/viewvc?rev=773976&view=rev
Log:
THRIFT-349. php: Accelerated binary protocol serialization segementation fault

Check to make sure that the object being serialized has a valid struct spec, 
error otherwise.


Modified:
    
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp

Modified: 
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp?rev=773976&r1=773975&r2=773976&view=diff
==============================================================================
--- 
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp 
(original)
+++ 
incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp 
Tue May 12 16:53:23 2009
@@ -716,6 +716,9 @@
         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);
+      if (Z_TYPE_P(spec) != IS_ARRAY) {
+        throw_tprotocolexception("Attempt to send non-Thrift object as a 
T_STRUCT", INVALID_DATA);
+      }
       binary_serialize_spec(*value, transport, Z_ARRVAL_P(spec));
     } return;
     case T_BOOL:
@@ -917,6 +920,9 @@
     }
 
     zval* spec = zend_read_static_property(zend_get_class_entry(request_struct 
TSRMLS_CC), "_TSPEC", 6, false TSRMLS_CC);
+    if (Z_TYPE_P(spec) != IS_ARRAY) {
+        throw_tprotocolexception("Attempt to send non-Thrift object", 
INVALID_DATA);
+    }
     binary_serialize_spec(request_struct, transport, Z_ARRVAL_P(spec));
   } catch (const PHPExceptionWrapper& ex) {
     zend_throw_exception_object(ex TSRMLS_CC);


Reply via email to