Avoid undefined behaviour const_casting std::string c_str()
Use non-const data() instead See: #224
This commit is contained in:
@@ -946,7 +946,7 @@ void NetworkGameLoop()
|
||||
cp->text.resize(MAX_CMD_TEXT_LENGTH);
|
||||
static_assert(MAX_CMD_TEXT_LENGTH > 8192);
|
||||
int ret = sscanf(p, "date{%x; %x; %x}; company: %x; tile: %x (%*u x %*u); p1: %x; p2: %x; p3: " OTTD_PRINTFHEX64 "; cmd: %x; \"%8192[^\"]\"",
|
||||
&next_date, &next_date_fract, &next_tick_skip_counter, &company, &cp->tile, &cp->p1, &cp->p2, &cp->p3, &cp->cmd, const_cast<char *>(cp->text.c_str()));
|
||||
&next_date, &next_date_fract, &next_tick_skip_counter, &company, &cp->tile, &cp->p1, &cp->p2, &cp->p3, &cp->cmd, cp->text.data());
|
||||
/* There are 10 pieces of data to read, however the last is a
|
||||
* string that might or might not exist. Ignore it if that
|
||||
* string misses because in 99% of the time it's not used. */
|
||||
|
Reference in New Issue
Block a user