]> granicus.if.org Git - php/commitdiff
Fixed custom unserialixe() in unicode mode
authorDmitry Stogov <dmitry@php.net>
Mon, 9 Jul 2007 15:58:52 +0000 (15:58 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 9 Jul 2007 15:58:52 +0000 (15:58 +0000)
ext/standard/var_unserializer.c
ext/standard/var_unserializer.re

index 68485be65c2299a9ce54b66a74c551ed62af0c54..7fc7dce1bc73ab1587acb93f6859f52d223cc3cb 100644 (file)
@@ -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);
 }
index 0486a90818e2d495972ade0416f82eb7aed53c18..9b798a3b89df97fc848e19640b1e3960d6b529e9 100644 (file)
@@ -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);
 }