undefined behaviour in Verilated::commandArgsPlusMatch #987
Labels
area: wrong runtime result
Issue involves an incorrect runtine result from Verilated model
resolution: fixed
Closed; fixed
Author Name: Jamie Iles (@jamieiles)
Original Redmine Issue: 987 from https://www.veripool.org
Original Date: 2015-10-29
Verilated::commandArgsPlusMatch calls c_str() on an automatic std::string and returns that. When the application uses that memory it can be pointing to something else rather than the string. I saw this on 3.874-1 in Ubuntu Wily which happened to work on the Ubuntu Vivid version by luck.
Changing to strdup the c_str() is the least invasive change, we could use static data, but that could break applications that expect the pointer to remain valid for the life of the application. I've attached a minimal patch to do this.
The text was updated successfully, but these errors were encountered: