mirror of
https://github.com/polybar/polybar.git
synced 2026-02-07 13:35:30 +00:00
fix: Stop using ato* for string to num conversion
atoi, atof and so on have undefined behavior if anything goes wrong. We now use strto*, but without error checking. In most places overflows and the like *should* not happen. String to number conversions are only used when reading data from other applications or from the config, if another application gives unparsable strings or too large numbers, then most likely there is something wrong with that application. If the error comes from the user config, then the user has to live with values provided by strto* on error (which are very reasonable) Fixes #1201
This commit is contained in:
@ -123,7 +123,7 @@ void builder::node(string str, bool add_space) {
|
||||
s.erase(0, 5);
|
||||
|
||||
} else if ((n = s.find("%{T")) == 0 && (m = s.find('}')) != string::npos) {
|
||||
font(atoi(s.substr(n + 3, m - 3).c_str()));
|
||||
font(strtol(s.substr(n + 3, m - 3).c_str(), nullptr, 10));
|
||||
s.erase(n, m + 1);
|
||||
|
||||
} else if ((n = s.find("%{U-}")) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user