You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compiler flagged a number of potential errors with the use of strncpy(), which have been fixed with #283.
However, there might be other such errors.
Also, null-terminated strings could introduce obscure bugs if any strings have embedded nulls (unlikely, but possible).
And the current code does its own buffer handling, re-allocating the buffers if needed when appending.
A better solution is to use std::string -- it handles buffer reallocation and also can handle nulls within strings.
Making this change would reduce the amount of code somewhat, which would reduce the probability of errors.
It would also probably help to change functions that pass char* parameters or return char* values (or update char** parameters). For public APIs, the existing char* ones could be preserved by adding equivalent std::string or const std::string& APIs.
If you wish some help with making these changes, please ask.
The text was updated successfully, but these errors were encountered:
Another potential bug that should have been fixed with std::vector: ba7742a (this was discovered by a compiler warning).
In general, most raw pointers in the code should be replaced by std::string, std::vector, std::unique_ptr, or local stack, as appropriate, which would simplify the code in many places (especially where the pointer is reallocated because a larger buffer is needed).
The compiler flagged a number of potential errors with the use of strncpy(), which have been fixed with #283.
However, there might be other such errors.
Also, null-terminated strings could introduce obscure bugs if any strings have embedded nulls (unlikely, but possible).
And the current code does its own buffer handling, re-allocating the buffers if needed when appending.
A better solution is to use
std::string
-- it handles buffer reallocation and also can handle nulls within strings.Making this change would reduce the amount of code somewhat, which would reduce the probability of errors.
It would also probably help to change functions that pass
char*
parameters or returnchar*
values (or updatechar**
parameters). For public APIs, the existingchar*
ones could be preserved by adding equivalentstd::string
orconst std::string&
APIs.If you wish some help with making these changes, please ask.
The text was updated successfully, but these errors were encountered: