-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.Issues and PRs related to general changes in the lib or src directory.testIssues and PRs related to the tests.Issues and PRs related to the tests.
Description
The following patch makes the base64 cctest fail for me:
diff --git a/test/cctest/test_base64.cc b/test/cctest/test_base64.cc
index fbdb969b4cbe..ecb61aa84cea 100644
--- a/test/cctest/test_base64.cc
+++ b/test/cctest/test_base64.cc
@@ -12,7 +12,7 @@ TEST(Base64Test, Encode) {
auto test = [](const char* string, const char* base64_string) {
const size_t len = strlen(base64_string);
char* const buffer = new char[len + 1];
- buffer[len] = 0;
+ memset(buffer, 0, len+1);
base64_encode(string, strlen(string), buffer, len);
EXPECT_STREQ(base64_string, buffer);
delete[] buffer;
@@ -48,7 +48,7 @@ TEST(Base64Test, Decode) {
auto test = [](const char* base64_string, const char* string) {
const size_t len = strlen(string);
char* const buffer = new char[len + 1];
- buffer[len] = 0;
+ memset(buffer, 0, len+1);
base64_decode(buffer, len, base64_string, strlen(base64_string));
EXPECT_STREQ(string, buffer);
delete[] buffer;That shouldn’t be happening, because buffer might be 0-initialized anyway. Without this patch, valgrind complains that we use uninitialized parts of buffer (rightfully so, I assume).
I don’t have the time to look into this right now, but I assume either the test is just asserting the wrong values, or something’s off with our base64 decoder implementation.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.Issues and PRs related to general changes in the lib or src directory.testIssues and PRs related to the tests.Issues and PRs related to the tests.