mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
base64_decode: Avoid code duplication in failures
This commit is contained in:
parent
7a02704c0e
commit
0981e5de3c
1 changed files with 6 additions and 4 deletions
|
@ -152,8 +152,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
|
|||
/* 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) {
|
||||
zend_string_free(result);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
padding++;
|
||||
continue;
|
||||
|
@ -172,8 +171,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
|
|||
}
|
||||
/* fail on bad characters or if any data follows padding */
|
||||
if (ch == -2 || padding) {
|
||||
zend_string_free(result);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,6 +198,10 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
|
|||
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
|
||||
|
||||
return result;
|
||||
|
||||
fail:
|
||||
zend_string_free(result);
|
||||
return NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue