From: Grigori Goronzy Date: Wed, 10 May 2017 11:39:57 +0000 (+0200) Subject: Fix PlayResX/Y calculations X-Git-Tag: 0.13.7~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cf8d6bb3e6b75f8215b69f697b6b5c05b1c1dd2;p=libass Fix PlayResX/Y calculations Avoid that PlayResY is set to 0 when only PlayResX is specified and set to 1. Setting PlayResY to 0 results in divide-by-zero errors. Also fix PlayResX calculations in case only PlayResY is specified, for completeness. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1474. --- diff --git a/libass/ass.c b/libass/ass.c index 159391d..c3bc6e5 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -1345,7 +1345,7 @@ void ass_lazy_track_init(ASS_Library *lib, ASS_Track *track) ass_msg(lib, MSGL_WARN, "PlayResY undefined, setting to %d", track->PlayResY); } else if (track->PlayResY <= 0) { - track->PlayResY = track->PlayResX * 3 / 4; + track->PlayResY = FFMAX(1, track->PlayResX * 3 / 4); ass_msg(lib, MSGL_WARN, "PlayResY undefined, setting to %d", track->PlayResY); } else if (track->PlayResX <= 0 && track->PlayResY == 1024) { @@ -1353,7 +1353,7 @@ void ass_lazy_track_init(ASS_Library *lib, ASS_Track *track) ass_msg(lib, MSGL_WARN, "PlayResX undefined, setting to %d", track->PlayResX); } else if (track->PlayResX <= 0) { - track->PlayResX = track->PlayResY * 4 / 3; + track->PlayResX = FFMAX(1, track->PlayResY * 4 / 3); ass_msg(lib, MSGL_WARN, "PlayResX undefined, setting to %d", track->PlayResX); }