diff options
author | Thies C. Arntzen <thies@php.net> | 2002-03-19 11:25:21 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 2002-03-19 11:25:21 +0000 |
commit | 3550d75d0fd81871bb2fe68ce65e17fc84ba7b52 (patch) | |
tree | abe490078808e64c60a3ba30a8e7317a4f49fd6e /ext/standard/var.c | |
parent | 737ea7691a8efcb7b923da1200e53d76331e78df (diff) | |
download | php-git-3550d75d0fd81871bb2fe68ce65e17fc84ba7b52.tar.gz |
fix #12793 - serialize will now spit a notice if the return value of __sleep is
bogus.
Diffstat (limited to 'ext/standard/var.c')
-rw-r--r-- | ext/standard/var.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/standard/var.c b/ext/standard/var.c index 7eb7410243..82dc118167 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -536,9 +536,15 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va if (res == SUCCESS) { if (retval_ptr) { - if (HASH_OF(retval_ptr)) + if (HASH_OF(retval_ptr)) { php_var_serialize_class(buf, struc, retval_ptr, var_hash TSRMLS_CC); + } else { + php_error(E_NOTICE, "__sleep should return an array only " + "containing the names of instance-variables to " + "serialize."); + } + zval_ptr_dtor(&retval_ptr); } return; @@ -623,7 +629,12 @@ PHP_FUNCTION(serialize) PHP_VAR_SERIALIZE_INIT(var_hash); php_var_serialize(&buf, struc, &var_hash TSRMLS_CC); PHP_VAR_SERIALIZE_DESTROY(var_hash); - RETVAL_STRINGL(buf.c, buf.len, 0); + + if (buf.c) { + RETURN_STRINGL(buf.c, buf.len, 0); + } else { + RETURN_NULL(); + } } /* }}} */ |