| Index: Source/wtf/text/Base64.cpp
|
| diff --git a/Source/wtf/text/Base64.cpp b/Source/wtf/text/Base64.cpp
|
| index d40e292d4aecb5f12ebbf371cb4fb42177015945..20ac803e4279fc8fa2311b80357f1fc35802dbce 100644
|
| --- a/Source/wtf/text/Base64.cpp
|
| +++ b/Source/wtf/text/Base64.cpp
|
| @@ -149,22 +149,34 @@ static inline bool base64DecodeInternal(const T* data, unsigned length, Vector<c
|
|
|
| unsigned equalsSignCount = 0;
|
| unsigned outLength = 0;
|
| + bool hadError = false;
|
| for (unsigned idx = 0; idx < length; ++idx) {
|
| unsigned ch = data[idx];
|
| if (ch == '=') {
|
| ++equalsSignCount;
|
| // There should never be more than 2 padding characters.
|
| - if (policy == Base64ValidatePadding && equalsSignCount > 2)
|
| - return false;
|
| + if (policy == Base64ValidatePadding && equalsSignCount > 2) {
|
| + hadError = true;
|
| + break;
|
| + }
|
| } else if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ch == '+' || ch == '/') {
|
| - if (equalsSignCount)
|
| - return false;
|
| + if (equalsSignCount) {
|
| + hadError = true;
|
| + break;
|
| + }
|
| out[outLength++] = base64DecMap[ch];
|
| } else if (!shouldIgnoreCharacter || !shouldIgnoreCharacter(ch)) {
|
| - return false;
|
| + hadError = true;
|
| + break;
|
| }
|
| }
|
|
|
| + if (outLength < out.size())
|
| + out.shrink(outLength);
|
| +
|
| + if (hadError)
|
| + return false;
|
| +
|
| if (!outLength)
|
| return !equalsSignCount;
|
|
|
|
|