diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c index de00b7141..4400e111c 100644 --- a/sway/commands/input/map_from_region.c +++ b/sway/commands/input/map_from_region.c @@ -11,11 +11,21 @@ static bool parse_coords(const char *str, double *x, double *y, bool *mm) { *mm = false; char *end; - *x = strtod(str, &end); - if (end[0] != 'x') { - return false; + + // Check for "0x" prefix to avoid strtod treating the string as hex + if (str[0] == '0' && str[1] == 'x') { + if (strlen(str) < 3) { + return false; + } + *x = 0; + end = (char *)str + 2; + } else { + *x = strtod(str, &end); + if (end[0] != 'x') { + return false; + } + ++end; } - ++end; *y = strtod(end, &end); if (end[0] == 'm') {