summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorllyyr <llyyr.public@gmail.com>2023-08-11 15:43:14 +0530
committersfan5 <sfan5@live.de>2023-08-11 13:04:52 +0200
commitb51036cdc00c6be343abbc29336e48c560553b89 (patch)
treec0f0e4f3ae6e8a35b86a21918153fe3acbb04556 /player
parent13c6e060e2316d12e34d2983dcc15eecef645900 (diff)
downloadmpv-b51036cdc00c6be343abbc29336e48c560553b89.tar.bz2
mpv-b51036cdc00c6be343abbc29336e48c560553b89.tar.xz
command: fix stack smashing when displaying aspect-ratio
1df0a42a8cb12005311f6a03f3a1c4329c798f8c changed aspect-ratio from floats to doubles, but forgot to change this function for pretty-printing them as fractions for the video-aspect-override property
Diffstat (limited to 'player')
-rw-r--r--player/command.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/player/command.c b/player/command.c
index 9886201b53..bf30a55968 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2800,29 +2800,25 @@ skip_warn: ;
return M_PROPERTY_NOT_IMPLEMENTED;
}
-static bool floats_equal(float x, float y) {
- float TOLERANCE = 0.001;
- float difference = fabsf(x - y);
- return difference <= TOLERANCE;
-}
+#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
static int mp_property_video_aspect_override(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (action == M_PROPERTY_PRINT) {
- float aspect_ratio;
+ double aspect_ratio;
mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &aspect_ratio);
- if (floats_equal(aspect_ratio, 2.35F / 1.0F))
+ if (doubles_equal(aspect_ratio, 2.35 / 1.0))
*(char **)arg = talloc_asprintf(NULL, "2.35:1");
- else if (floats_equal(aspect_ratio, 16.0F / 9.0F))
+ else if (doubles_equal(aspect_ratio, 16.0 / 9.0))
*(char **)arg = talloc_asprintf(NULL, "16:9");
- else if (floats_equal(aspect_ratio, 16.0F / 10.0F))
+ else if (doubles_equal(aspect_ratio, 16.0 / 10.0))
*(char **)arg = talloc_asprintf(NULL, "16:10");
- else if (floats_equal(aspect_ratio, 4.0F / 3.0F))
+ else if (doubles_equal(aspect_ratio, 4.0 / 3.0))
*(char **)arg = talloc_asprintf(NULL, "4:3");
- else if (floats_equal(aspect_ratio, -1.0F))
+ else if (doubles_equal(aspect_ratio, -1.0))
*(char **)arg = talloc_asprintf(NULL, "Original");
else
*(char **)arg = talloc_asprintf(NULL, "%.3f", aspect_ratio);