osd_libass: fix integer overflow in osd_get_text_size()

If show-text ${playlist} is used with --osd-scale-by-window=no while
printing to the terminal or while mpv is starting, the out_screen_h
assignment in osd_get_text_size() causes runtime error: signed integer
overflow: 288 - -2147483648 cannot be represented in type 'int'. Fix
this by not making prepare_osd_ass() use an infinite playresy.

This prevents printing show-text ${playlist} without a line limit to the
terminal with --osd-scale-by-window=no, which makes only the last
playlist entries be printed, and the selected one is not printed if it
isn't among them. A later commit will make the line calculation
accurate.
This commit is contained in:
Guido Cella 2024-10-12 22:59:59 +02:00 committed by Kacper Michajłow
parent 0f74b1bc2d
commit 4e4d6a16d8
1 changed files with 1 additions and 1 deletions

View File

@ -256,7 +256,7 @@ static ASS_Style *prepare_osd_ass(struct osd_state *osd, struct osd_object *obj)
double playresy = obj->ass.track->PlayResY; double playresy = obj->ass.track->PlayResY;
// Compensate for libass and mp_ass_set_style scaling the font etc. // Compensate for libass and mp_ass_set_style scaling the font etc.
if (!opts->osd_scale_by_window) if (!opts->osd_scale_by_window && obj->vo_res.h)
playresy *= 720.0 / obj->vo_res.h; playresy *= 720.0 / obj->vo_res.h;
ASS_Style *style = get_style(&obj->ass, "OSD"); ASS_Style *style = get_style(&obj->ass, "OSD");