summaryrefslogtreecommitdiff
path: root/ext/bz2
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-04-25 20:43:11 +0200
committerNikita Popov <nikic@php.net>2015-04-27 18:50:08 +0200
commit40e465e3575443757693146bb141a4de02cc697c (patch)
tree6eb7c1fc0ffeb24d3bcf3cc34ecd294c39a2e4e4 /ext/bz2
parent1800bed1045a43d2478c0265a26fe0675fb5a6c1 (diff)
downloadphp-git-40e465e3575443757693146bb141a4de02cc697c.tar.gz
Clean up some type conversions
While at it also fix some type checks in iconv and drop dead and unported code in standard/filters.
Diffstat (limited to 'ext/bz2')
-rw-r--r--ext/bz2/bz2_filter.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c
index c2710d99f9..c0e128a9e1 100644
--- a/ext/bz2/bz2_filter.c
+++ b/ext/bz2/bz2_filter.c
@@ -377,28 +377,21 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
if (Z_TYPE_P(filterparams) == IS_ARRAY || Z_TYPE_P(filterparams) == IS_OBJECT) {
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "blocks", sizeof("blocks")-1))) {
/* How much memory to allocate (1 - 9) x 100kb */
- zval tmp;
-
- ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
- if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%pd)", Z_LVAL_P(tmpzval));
+ zend_long blocks = zval_get_long(tmpzval);
+ if (blocks < 1 || blocks > 9) {
+ php_error_docref(NULL, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%pd)", blocks);
} else {
- blockSize100k = (int)Z_LVAL(tmp);
+ blockSize100k = (int) blocks;
}
}
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "work", sizeof("work")-1))) {
/* Work Factor (0 - 250) */
- zval tmp;
-
- ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
-
- if (Z_LVAL(tmp) < 0 || Z_LVAL(tmp) > 250) {
- php_error_docref(NULL, E_WARNING, "Invalid parameter given for work factor. (%pd)", Z_LVAL(tmp));
+ zend_long work = zval_get_long(tmpzval);
+ if (work < 0 || work > 250) {
+ php_error_docref(NULL, E_WARNING, "Invalid parameter given for work factor. (%pd)", work);
} else {
- workFactor = (int)Z_LVAL(tmp);
+ workFactor = (int) work;
}
}
}