parse_timecode: use signed variable for value containing negative values

size_t is usually an unsigned value. Storing -1 in it and expecting the
following multiplication to result in a negative value only works on
architectures where sizeof(size_t) == sizeof(int64_t), meaning on 64bit
platforms. On 32bit Windows »negative« would contain MAX_UINT32 instead
of MAX_UINT64 resulting in wrong results.

Fixes #1425.
This commit is contained in:
Moritz Bunkus 2015-09-13 10:21:46 +02:00
parent a4984c1e97
commit 0c862c2ce7
2 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2015-09-13 Moritz Bunkus <moritz@bunkus.org>
* all: bug fix: parsing of strings containing negative values or
timecodes was broken on 32bit architectures. Fixes #1425.
2015-09-05 Moritz Bunkus <moritz@bunkus.org>
* MKVToolNix GUI: new merge tool feature: added a column in the

View File

@ -41,8 +41,8 @@ parse_timecode(const std::string &src,
// HH: is optional; HH, MM and SS can be either one or two digits.
// 2. HH:MM:SS:nnnnnnnnn with up to nine digits 'n' for ns precision;
// HH: is optional; HH, MM and SS can be either one or two digits.
int h, m, s, n, values[4], num_values, num_digits, num_colons;
size_t offset = 0, negative = 1, i;
int h, m, s, n, values[4], num_values, num_digits, num_colons, negative = 1;
size_t offset = 0, i;
bool decimal_point_found;
if (src.empty())