From: Dmitry Stogov Date: Mon, 9 Jul 2007 15:58:52 +0000 (+0000) Subject: Fixed custom unserialixe() in unicode mode X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~286 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7b6c29857068f834993262604da5405a2c05e87;p=php Fixed custom unserialixe() in unicode mode --- diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 68485be65c..7fc7dce1bc 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -359,6 +359,8 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { long datalen; int type; + zstr buf; + size_t buf_len; if(ce->unserialize == NULL) { zend_error(E_WARNING, "Class %v has no unserializer", ce->name); @@ -389,11 +391,23 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) return 0; } - if(ce->unserialize(rval, ce, type, ZSTR((char*)*p), datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { + if (type == IS_UNICODE) { + buf.u = unserialize_ustr(p, datalen); + buf_len = u_strlen(buf.u); + } else { + buf.s = (char*)*p; + buf_len = datalen; + (*p) += datalen; + } + if(ce->unserialize(rval, ce, type, buf, buf_len, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { + if (type == IS_UNICODE) { + efree(buf.v); + } return 0; } - - (*p) += datalen; + if (type == IS_UNICODE) { + efree(buf.v); + } return finish_nested_data(UNSERIALIZE_PASSTHRU); } diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 0486a90818..9b798a3b89 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -363,6 +363,8 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { long datalen; int type; + zstr buf; + size_t buf_len; if(ce->unserialize == NULL) { zend_error(E_WARNING, "Class %v has no unserializer", ce->name); @@ -393,11 +395,23 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) return 0; } - if(ce->unserialize(rval, ce, type, ZSTR((char*)*p), datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { + if (type == IS_UNICODE) { + buf.u = unserialize_ustr(p, datalen); + buf_len = u_strlen(buf.u); + } else { + buf.s = (char*)*p; + buf_len = datalen; + (*p) += datalen; + } + if(ce->unserialize(rval, ce, type, buf, buf_len, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { + if (type == IS_UNICODE) { + efree(buf.v); + } return 0; } - - (*p) += datalen; + if (type == IS_UNICODE) { + efree(buf.v); + } return finish_nested_data(UNSERIALIZE_PASSTHRU); }