[vlc-devel] [RFC 2/2] variables: Reduce InheritURational precision
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Mar 28 14:28:18 CEST 2016
When providing FPS as a floating number, this function can potentially return extremely high numbers.
For instance, with 29.97, it yields num=1005626327 and den=33554432
These numbers are then likely to be used for a date computation, which
again, during my tests, ends up overflowing the destination int64.
By reducing the precision, the results are more sensible (29.97 yields
30689/1024, which is much closer to the expected 30000/1001)
This is probably not the best fix, and the correct solution would be to
provide the FPS as a fraction to begin with, however it would seem
dubious to leave this issue persist.
---
src/misc/variables.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 50cdcea..ecae0c3 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -1305,7 +1305,7 @@ int (var_InheritURational)(vlc_object_t *object,
if (*next == '.') {
/* Interpret as a (finite positive) float number */
- const int ubits = CHAR_BIT * sizeof (unsigned);
+ const int ubits = CHAR_BIT * sizeof (int16_t);
int exp;
double f = frexp(us_atof(tmp), &exp);
--
2.7.0
More information about the vlc-devel
mailing list