Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base64::encode: Adjusted buffer size algorithm #4934

Merged
merged 4 commits into from
Jul 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cores/esp8266/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ extern "C" {
* @return String
*/
String base64::encode(uint8_t * data, size_t length, bool doNewLines) {
// base64 needs more size then the source data
size_t size = ((length * 1.6f) + 1);
// base64 needs more size then the source data, use cencode.h macros
size_t size = ((doNewLines ? base64_encode_expected_len(length)
: base64_encode_expected_len_nonewlines(length)) + 1);
char * buffer = (char *) malloc(size);
if(buffer) {
base64_encodestate _state;
Expand Down