Skip to content

Instantly share code, notes, and snippets.

@Sean-Der
Created June 1, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sean-Der/f8cb8578f195dc563414 to your computer and use it in GitHub Desktop.
Save Sean-Der/f8cb8578f195dc563414 to your computer and use it in GitHub Desktop.
static ZEND_FUNCTION(msgpack_unserialize){
zval *object, *bool_val, *ref_val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &object) == FAILURE) {
return;
}
ALLOC_INIT_ZVAL(bool_val);
ZVAL_BOOL(bool_val, true);
ALLOC_INIT_ZVAL(ref_val);
array_init(ref_val);
Z_SET_ISREF_P(ref_val);
Z_ADDREF_PP(&ref_val);
zend_symtable_update(HASH_OF(object), "", sizeof(""), &bool_val, sizeof(bool_val), NULL);
zend_symtable_update(HASH_OF(object), "ref_val", sizeof("ref_val"), &ref_val, sizeof(ref_val), NULL);
zend_hash_index_update(HASH_OF(object), 4, &bool_val, sizeof(bool_val), NULL);
}
<?php
error_reporting(0);
class Obj {
}
$obj = new Obj();
msgpack_unserialize($obj);
var_dump($obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment