X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/base64.cpp?ds=sidebyside diff --git a/src/common/base64.cpp b/src/common/base64.cpp index bf5a613dff..d83daee682 100644 --- a/src/common/base64.cpp +++ b/src/common/base64.cpp @@ -187,8 +187,15 @@ wxBase64Decode(void *dst_, size_t dstLen, // undo the bit shifting done during encoding *dst++ = in[0] << 2 | in[1] >> 4; - *dst++ = in[1] << 4 | in[2] >> 2; - *dst++ = in[2] << 6 | in[3]; + + // be careful to not overwrite the output buffer with NUL pad + // bytes + if ( padLen != 2 ) + { + *dst++ = in[1] << 4 | in[2] >> 2; + if ( !padLen ) + *dst++ = in[2] << 6 | in[3]; + } } n = 0;