8000 Fixing serializer initialization and destruction in PHP 5.4. · jrtkcoder/phpredis@158d90b · GitHub
[go: up one dir, main page]

Skip to content

Commit 158d90b

Browse files
maxbeutelnicolasff
authored andcommitted
Fixing serializer initialization and destruction in PHP 5.4.
1 parent 38e2cca commit 158d90b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,13 +1286,15 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_
12861286
case REDIS_SERIALIZER_PHP:
12871287

12881288
#if ZEND_MODULE_API_NO >= 20100000
1289+
PHP_VAR_SERIALIZE_INIT(ht);
12891290
#else
12901291
zend_hash_init(&ht, 10, NULL, NULL, 0);
12911292
#endif
12921293
php_var_serialize(&sstr, &z, &ht TSRMLS_CC);
12931294
*val = sstr.c;
12941295
*val_len = (int)sstr.len;
12951296
#if ZEND_MODULE_API_NO >= 20100000
1297+
PHP_VAR_SERIALIZE_DESTROY(ht);
12961298
#else
12971299
zend_hash_destroy(&ht);
12981300
#endif
@@ -1324,15 +1326,23 @@ redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **re
13241326
if(!*return_value) {
13251327
MAKE_STD_ZVAL(*return_value);
13261328
}
1329+
#if ZEND_MODULE_API_NO >= 20100000
1330+
PHP_VAR_UNSERIALIZE_INIT(var_hash);
1331+
#else
13271332
memset(&var_hash, 0, sizeof(var_hash));
1333+
#endif
13281334
if(!php_var_unserialize(return_value, (const unsigned char**)&val,
13291335
(const unsigned char*)val + val_len, &var_hash TSRMLS_CC)) {
13301336
efree(*return_value);
13311337
ret = 0;
13321338
} else {
13331339
ret = 1;
13341340
}
1341+
#if ZEND_MODULE_API_NO >= 20100000
1342+
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
1343+
#else
13351344
var_destroy(&var_hash);
1345+
#endif
13361346

13371347
return ret;
13381348

0 commit comments

Comments
 (0)
0