mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 04:25:58 +01:00
fix: prevent potential crash in handleBezier due to invalid input
before, when the conf file contained anything other than a float in the 4 bezier curve generation points for annimations, it crashed Hyprland, which now returns an error message.
This commit is contained in:
parent
553232a3e4
commit
ed7cefdd3a
1 changed files with 13 additions and 19 deletions
|
@ -1821,26 +1821,20 @@ std::optional<std::string> CConfigManager::handleBezier(const std::string& comma
|
|||
const auto ARGS = CVarList(args);
|
||||
|
||||
std::string bezierName = ARGS[0];
|
||||
if (ARGS[1] == "" || ARGS[2] == "" || ARGS[3] == "" || ARGS[4] == "")
|
||||
return "too few arguments";
|
||||
if (ARGS[5]!= "")
|
||||
return "too many arguments";
|
||||
|
||||
if (ARGS[1] == "")
|
||||
return "too few arguments";
|
||||
float p1x = std::stof(ARGS[1]);
|
||||
|
||||
if (ARGS[2] == "")
|
||||
return "too few arguments";
|
||||
float p1y = std::stof(ARGS[2]);
|
||||
|
||||
if (ARGS[3] == "")
|
||||
return "too few arguments";
|
||||
float p2x = std::stof(ARGS[3]);
|
||||
|
||||
if (ARGS[4] == "")
|
||||
return "too few arguments";
|
||||
float p2y = std::stof(ARGS[4]);
|
||||
|
||||
if (ARGS[5] != "")
|
||||
return "too many arguments";
|
||||
|
||||
float p1x = 0, p1y = 0, p2x = 0, p2y = 0;
|
||||
try {
|
||||
p1x = std::stof(ARGS[1]);
|
||||
p1y = std::stof(ARGS[2]);
|
||||
p2x = std::stof(ARGS[3]);
|
||||
p2y = std::stof(ARGS[4]);
|
||||
} catch (const std::invalid_argument&) {
|
||||
return "invalid argument";
|
||||
}
|
||||
g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y));
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Reference in a new issue