X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..cc4d5638c66a409e421420ed7110917755a66788:/src/common/base64.cpp?ds=sidebyside diff --git a/src/common/base64.cpp b/src/common/base64.cpp index bf5a613dff..5ee3a7a3c7 100644 --- a/src/common/base64.cpp +++ b/src/common/base64.cpp @@ -3,7 +3,6 @@ // Purpose: implementation of BASE64 encoding/decoding functions // Author: Charles Reimers, Vadim Zeitlin // Created: 2007-06-18 -// RCS-ID: $Id$ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -187,8 +186,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;