diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index bba49663..9f40df31 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -25,6 +25,8 @@ #include "asffile.h" +#include + #include #include "tdebug.h" @@ -236,8 +238,14 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, long l const long long duration = data.toLongLong(40, false); const long long preroll = data.toLongLong(56, false); - file->d->properties->setLengthInMilliseconds( - static_cast(static_cast(duration) / 10000.0 - static_cast(preroll) + 0.5)); + // duration and preroll are both read from the file, so the result can land outside + // int, and converting a double the destination type cannot represent is undefined. + const double milliseconds = + static_cast(duration) / 10000.0 - static_cast(preroll) + 0.5; + + if(milliseconds > static_cast(std::numeric_limits::min()) && + milliseconds < static_cast(std::numeric_limits::max())) + file->d->properties->setLengthInMilliseconds(static_cast(milliseconds)); } ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const