com php-src: Tweak new deflate/inflate implementations: ext/zlib/tests/inflate_init_error.phpt ext/zlib/zlib. c

From: Date: Sat, 25 Apr 2015 17:00:41 +0000
Subject: com php-src: Tweak new deflate/inflate implementations: ext/zlib/tests/inflate_init_error.phpt ext/zlib/zlib. c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86482@lists.php.net to get a copy of this message
Commit: 300b1db09fc093c7224bb3e1016534378fcf92bc Author: Nikita Popov <nikic@php.net> Sat, 25 Apr 2015 19:00:41 +0200 Parents: 75b4fa079f1c13188895bfbe47dc561e17c59382 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=300b1db09fc093c7224bb3e1016534378fcf92bc Log: Tweak new deflate/inflate implementations Return NULL on zpp. Don't manually cast zvals to long. Changed paths: M ext/zlib/tests/inflate_init_error.phpt M ext/zlib/zlib.c Diff: diff --git a/ext/zlib/tests/inflate_init_error.phpt b/ext/zlib/tests/inflate_init_error.phpt index ad1410c..0e0e8b3 100644 --- a/ext/zlib/tests/inflate_init_error.phpt +++ b/ext/zlib/tests/inflate_init_error.phpt @@ -14,7 +14,7 @@ var_dump(inflate_init(42)); --EXPECTF-- Warning: inflate_init() expects exactly 1 parameter, 0 given in %s on line %d -bool(false) +NULL Warning: inflate_init(): encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d bool(false) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 957be34..7fcb6a1 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -760,7 +760,7 @@ PHP_FUNCTION(inflate_init) zend_long encoding; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l", &encoding)) { - RETURN_FALSE; + return; } switch (encoding) { @@ -801,7 +801,7 @@ PHP_FUNCTION(inflate_add) int status; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &res, &in_buf, &in_len, &flush_type)) { - RETURN_FALSE; + return; } if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { @@ -885,21 +885,14 @@ PHP_FUNCTION(deflate_init) z_stream *ctx; zend_long encoding, level = -1, memory = 8; HashTable *options = 0; - zval *option_buffer, cast_option_buffer; + zval *option_buffer; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l|H", &encoding, &options)) { - RETURN_FALSE; + return; } - if (options && (option_buffer = zend_symtable_str_find(options, "level", sizeof("level")-1)) != NULL) { - if (Z_TYPE_P(option_buffer) != IS_LONG) { - ZVAL_DUP(&cast_option_buffer, option_buffer); - convert_to_long(&cast_option_buffer); - level = Z_LVAL(cast_option_buffer); - zval_dtor(&cast_option_buffer); - } else { - level = Z_LVAL_P(option_buffer); - } + if (options && (option_buffer = zend_hash_str_find(options, "level", sizeof("level")-1)) != NULL) { + level = zval_get_long(option_buffer); } if (level < -1 || level > 9) { php_error_docref(NULL, E_WARNING, "compression level (%pd) must be within -1..9", level); @@ -907,14 +900,7 @@ PHP_FUNCTION(deflate_init) } if (options && (option_buffer = zend_symtable_str_find(options, "memory", sizeof("memory")-1)) != NULL) { - if (Z_TYPE_P(option_buffer) != IS_LONG) { - ZVAL_DUP(&cast_option_buffer, option_buffer); - convert_to_long(&cast_option_buffer); - memory = Z_LVAL(cast_option_buffer); - zval_dtor(&cast_option_buffer); - } else { - memory = Z_LVAL_P(option_buffer); - } + memory = zval_get_long(option_buffer); } if (memory < 1 || memory > 9) { php_error_docref(NULL, E_WARNING, "compression memory level (%pd) must be within 1..9", memory);

« previous php.cvs (#86482) next »