mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
RsBase64 handle correcly 0 lenght buffer encoding
This commit is contained in:
parent
d87abb45e3
commit
3332c32a84
@ -40,6 +40,12 @@
|
||||
rs_view_ptr<const uint8_t> data, size_t len, std::string& outString,
|
||||
bool padding, bool urlSafe )
|
||||
{
|
||||
if(!data || !len)
|
||||
{
|
||||
outString.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const char* sDict = urlSafe ? uDict : bDict;
|
||||
|
||||
// Workaround if input and output are the same buffer.
|
||||
@ -137,6 +143,7 @@
|
||||
|
||||
/*static*/ size_t RsBase64::encodedSize(size_t decodedSize, bool padding)
|
||||
{
|
||||
if(!decodedSize) return 0;
|
||||
if(padding) return 4 * (decodedSize + 2) / 3;
|
||||
return static_cast<size_t>(
|
||||
std::ceil(4L * static_cast<double>(decodedSize) / 3L) );
|
||||
|
Loading…
Reference in New Issue
Block a user