mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 12:00:26 +02:00
Merge pull request #204 from ChupathingyCE/upstream-fix/stb-vorbis-codebooks
stb_vorbis: refuse code books of no dimensions, compare large powers as floats
This commit is contained in:
commit
dc9b3973f0
1 file changed
+10
-4
@@ -1243,12 +1243,18 @@ static int vorbis_validate(uint8 *data)
|
||||
// (formula implied by specification)
|
||||
static int lookup1_values(int entries, int dim)
|
||||
{
|
||||
int r = (int) floor(exp((float) log((float) entries) / dim));
|
||||
if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning;
|
||||
++r; // floor() to avoid _ftol() when non-CRT
|
||||
int r;
|
||||
// port: a code book of no dimensions or entries has no values (the
|
||||
// division below is by zero)
|
||||
if (dim <= 0 || entries <= 0) return -1;
|
||||
r = (int) floor(exp((float) log((float) entries) / dim));
|
||||
// port: the powers compared as they are, not cast to int first (a large
|
||||
// dim's are past an int, where the cast is undefined)
|
||||
if (floor(pow((float) r+1, dim)) <= entries)
|
||||
++r;
|
||||
if (pow((float) r+1, dim) <= entries)
|
||||
return -1;
|
||||
if ((int) floor(pow((float) r, dim)) > entries)
|
||||
if (floor(pow((float) r, dim)) > entries)
|
||||
return -1;
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user