Skip to content

Commit

Permalink
base64_decode: remove redundant check
Browse files Browse the repository at this point in the history
If length == 0 || *current != '=' is false, the for loop will always
end up in this same point, until the if statement becomes true.
Thus, the if statement is not needed.
  • Loading branch information
Metabolix authored and nikic committed Jul 5, 2016
1 parent 59d36bf commit fbc74bb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ext/standard/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
/* run through the whole string, converting as we go */
while (length-- > 0 && (ch = *current++) != '\0') {
if (ch == base64_pad) {
/* fail if the padding character is second in a group (like V===) */
/* FIXME: why do we still allow invalid padding in other places in the middle of the string? */
if (i % 4 == 1) {
if (length == 0 || *current != '=') {
zend_string_free(result);
return NULL;
}
} else if (length > 0 && *current != '=' && strict) {
zend_string_free(result);
return NULL;
}
if (length > 0 && *current != '=' && strict) {
while (--length > 0 && isspace(*++current)) {
continue;
}
Expand Down

0 comments on commit fbc74bb

Please sign in to comment.