mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
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.
This commit is contained in:
parent
c1ac081bf1
commit
0259459486
1 changed files with 1 additions and 15 deletions
|
@ -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) /* {{{ */
|
PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length, zend_bool strict) /* {{{ */
|
||||||
{
|
{
|
||||||
const unsigned char *current = str;
|
const unsigned char *current = str;
|
||||||
int ch, i = 0, j = 0, k;
|
int ch, i = 0, j = 0;
|
||||||
/* this sucks for threaded environments */
|
|
||||||
zend_string *result;
|
zend_string *result;
|
||||||
|
|
||||||
result = zend_string_alloc(length, 0);
|
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++;
|
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_LEN(result) = j;
|
||||||
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
|
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue