summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorChristoph Heinrich <christoph.heinrich@student.tugraz.at>2023-11-11 20:17:41 +0100
committerDudemanguy <random342@airmail.cc>2023-11-11 20:43:02 +0000
commit5db7dc08601fe857cfbc59704a2a1078d750e61e (patch)
treebba075530e6790903662563776846746e99843f6 /player/lua
parent438ead7a3d50468b8150f2dc2727b96c78db9874 (diff)
downloadmpv-5db7dc08601fe857cfbc59704a2a1078d750e61e.tar.bz2
mpv-5db7dc08601fe857cfbc59704a2a1078d750e61e.tar.xz
console: fix crash for long suggestion strings
String formatting of Lua crashes with widths greater then 99, so limit the value to that. A nicer solution would be to create our own string padding function that can handle bigger widths, but such long suggestions aren't common enough to be worth the effort.
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/console.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/player/lua/console.lua b/player/lua/console.lua
index a985a43498..44e943635e 100644
--- a/player/lua/console.lua
+++ b/player/lua/console.lua
@@ -214,8 +214,9 @@ function format_table(list, width_max, rows_max)
for column = 1, column_count do
local i = row + (column - 1) * row_count
if i > #list then break end
+ -- more then 99 leads to 'invalid format (width or precision too long)'
local format_string = column == column_count and '%s'
- or '%-' .. column_widths[column] .. 's'
+ or '%-' .. math.min(column_widths[column], 99) .. 's'
columns[column] = string.format(format_string, list[i])
end
-- first row is at the bottom