ToruNiina / toml11

TOML for Modern C++

Home Page:https://toruniina.github.io/toml11/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

basic_value& operator= not guarding against self-assignment

agricartel opened this issue · comments

commented

In operator=(const basic_value& v) and operator=(basic_value&& v), if v is the same object as this (&v == this), a segmentation fault occurs (Tested on Ubuntu 20.04 with gcc 9.4.0) when invoking operator=.

To reproduce the issue:

toml::value tmp_tab{{"variable", "test"}};
tab_ = toml::value{{"table", tmp_tab}};
tab_["table"] = tab_["table"];

Thank you for reporting! I reproduced the bug and added a quick patch.