Skip to content

Commit

Permalink
Fix problem (segfault) with serialize BloomFilter object (PHP 5.4) / …
Browse files Browse the repository at this point in the history
…version depend memory managment
  • Loading branch information
ziollek committed Sep 23, 2013
1 parent 76d24cb commit 36279a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions php_bloomy.c
Expand Up @@ -246,10 +246,10 @@ int php_bloom_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len
smart_str_append_unsigned(&buf, obj->bloom->salt2);
smart_str_appendc(&buf, ';');

if (var_hash != NULL) {
#if PHP_VERSION_ID > 50399
var_hash = emalloc(sizeof(php_serialize_data_t));
PHP_VAR_SERIALIZE_INIT(*var_hash);
}
#endif

INIT_PZVAL(&value);
ZVAL_DOUBLE(&value, obj->bloom->max_error_rate);
Expand All @@ -262,6 +262,10 @@ int php_bloom_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len
*buf_len = buf.len;
efree(buf.c);

#if PHP_VERSION_ID > 50399
PHP_VAR_SERIALIZE_DESTROY(*var_hash);
#endif

return SUCCESS;
}

Expand Down

0 comments on commit 36279a8

Please sign in to comment.