Skip to content
Snippets Groups Projects
Commit 21a18e22 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan :ant:
Browse files

avcfg: Ensure that ternary operator always evaluates to int64

When building with MSVC, if the 3rd operator is a double, the entire
expression always promoted double, and is then cast to int64.

When TRUE, this evaluates to (gint64) (gdouble) (INT64_MAX)
which overflows to INT64_MIN on MSVC, but not on C99 compilers.

This causes us to fail the g_return_if_fail inside g_param_spec_int64
when built with MSVC.
parent ef106350
No related branches found
No related tags found
No related merge requests found
...@@ -298,8 +298,8 @@ install_opts (GObjectClass * gobject_class, const AVClass ** obj, guint prop_id, ...@@ -298,8 +298,8 @@ install_opts (GObjectClass * gobject_class, const AVClass ** obj, guint prop_id,
case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_INT64:
/* ffmpeg expresses all ranges with doubles, this is sad */ /* ffmpeg expresses all ranges with doubles, this is sad */
pspec = g_param_spec_int64 (name, name, help, pspec = g_param_spec_int64 (name, name, help,
(gint64) (min == (gdouble) INT64_MIN ? INT64_MIN : min), (min == (gdouble) INT64_MIN ? INT64_MIN : (gint64) min),
(gint64) (max == (gdouble) INT64_MAX ? INT64_MAX : max), (max == (gdouble) INT64_MAX ? INT64_MAX : (gint64) max),
opt->default_val.i64, G_PARAM_READWRITE); opt->default_val.i64, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, prop_id++, pspec); g_object_class_install_property (gobject_class, prop_id++, pspec);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment