Skip to content

Conversation

@Gnorkus
Copy link

@Gnorkus Gnorkus commented Dec 4, 2025

There needs to be a check for zero length strings so that memmove does not get called to copy a zero length string and avoid a build break. C++ 20 can detect errors like this and stops the build.

There needs to be a check for zero length strings so that memmove does not get called to copy a zero length string and avoid a build break.  C++ 20 can detect errors like this and stops the build.
@Gnorkus Gnorkus requested a review from a team as a code owner December 4, 2025 16:39
@github-actions github-actions bot added the component: ntcore NetworkTables library label Dec 4, 2025
*out_len = in.size();
size_t n;
char* out = static_cast<char*>(wpi::safe_malloc(n + 1));
if (n>0)
Copy link
Member

@calcmogul calcmogul Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our style guide requires curly braces on control flow statements.

std::memmove(out, in.data(), in.size()); // NOLINT
out[in.size()] = '\0';
*out_len = in.size();
size_t n;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized variable?

@KangarooKoala
Copy link
Contributor

C++ 20 can detect errors like this and stops the build.

Can you please elaborate on this? We upgraded to C++20 three years ago and haven't noticed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: ntcore NetworkTables library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants