com php-src: base64_decode: remove redundant code : ext/standard/base64.c

From: Date: Wed, 06 Jul 2016 23:27:23 +0000
Subject: com php-src: base64_decode: remove redundant code : ext/standard/base64.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92850@lists.php.net to get a copy of this message
Commit: 0259459486dd50b30b97392f6fc8085e7bba772e Author: Lauri Kenttä <lauri.kentta@gmail.com> Wed, 25 May 2016 19:52:11 +0300 Committer: Nikita Popov <nikic@php.net> Thu, 7 Jul 2016 01:27:23 +0200 Parents: c1ac081bf1bdd8abb50e9a707bd4ea4a6389b735 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0259459486dd50b30b97392f6fc8085e7bba772e Log: base64_decode: remove redundant code case 1 is already handled in the first lines of the for loop; it would only be entered in the invalid case where the string continues past the defined length (ch != 0 but length-- == 0). case 2 and case 3 are redundant, since k >= j and later the string is truncated to j characters anyway. Changed paths: M ext/standard/base64.c Diff: diff --git a/ext/standard/base64.c b/ext/standard/base64.c index ea54815..dc3e520 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -136,8 +136,7 @@ PHPAPI zend_string *php_base64_decode(const unsigned char *str, size_t length) / PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length, zend_bool strict) /* {{{ */ { const unsigned char *current = str; - int ch, i = 0, j = 0, k; - /* this sucks for threaded environments */ + int ch, i = 0, j = 0; zend_string *result; result = zend_string_alloc(length, 0); @@ -197,19 +196,6 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length i++; } - k = j; - /* mop things up if we ended on a boundary */ - if (ch == base64_pad) { - switch(i % 4) { - case 1: - zend_string_free(result); - return NULL; - case 2: - k++; - case 3: - ZSTR_VAL(result)[k] = 0; - } - } ZSTR_LEN(result) = j; ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';

« previous php.cvs (#92850) next »