Commit b918d6e2 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/vorbis: return proper error codes from ff_vorbis_len2vlc()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d1122b7c
...@@ -71,7 +71,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) ...@@ -71,7 +71,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
codes[p] = 0; codes[p] = 0;
if (bits[p] > 32) if (bits[p] > 32)
return 1; return AVERROR_INVALIDDATA;
for (i = 0; i < bits[p]; ++i) for (i = 0; i < bits[p]; ++i)
exit_at_level[i+1] = 1 << i; exit_at_level[i+1] = 1 << i;
...@@ -87,7 +87,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) ...@@ -87,7 +87,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
for (; p < num; ++p) { for (; p < num; ++p) {
if (bits[p] > 32) if (bits[p] > 32)
return 1; return AVERROR_INVALIDDATA;
if (bits[p] == 0) if (bits[p] == 0)
continue; continue;
// find corresponding exit(node which the tree can grow further from) // find corresponding exit(node which the tree can grow further from)
...@@ -95,7 +95,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) ...@@ -95,7 +95,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
if (exit_at_level[i]) if (exit_at_level[i])
break; break;
if (!i) // overspecified tree if (!i) // overspecified tree
return 1; return AVERROR_INVALIDDATA;
code = exit_at_level[i]; code = exit_at_level[i];
exit_at_level[i] = 0; exit_at_level[i] = 0;
// construct code (append 0s to end) and introduce new exits // construct code (append 0s to end) and introduce new exits
...@@ -116,7 +116,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) ...@@ -116,7 +116,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
//no exits should be left (underspecified tree - ie. unused valid vlcs - not allowed by SPEC) //no exits should be left (underspecified tree - ie. unused valid vlcs - not allowed by SPEC)
for (p = 1; p < 33; p++) for (p = 1; p < 33; p++)
if (exit_at_level[p]) if (exit_at_level[p])
return 1; return AVERROR_INVALIDDATA;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment