avoid undefined behavior when parsing proc maps

Clang's undefined behavior sanitized correctly pointed out that
memmove requires non-nil args, so lets initialize sbuf to something.
This commit is contained in:
Aliaksey Kandratsenka 2024-02-17 18:05:07 -05:00
parent 9b5838f084
commit dec85dcc03

View File

@ -258,8 +258,10 @@ bool ForEachLine(const char* path, const Body& body) {
return false;
}
char* sbuf = nullptr;
char* ebuf = nullptr;
char* sbuf = buf; // note, initial value could be nullptr, but
// memmove actually insists to get non-null
// arguments (even when count is 0)
char* ebuf = sbuf;
bool eof = false;