Merge commit '7136a0bf88f31bb8d40a3bbd251963706fb14578' into release/2.4
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 8 Mar 2015 23:27:34 +0000 (00:27 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 8 Mar 2015 23:27:53 +0000 (00:27 +0100)
* commit '7136a0bf88f31bb8d40a3bbd251963706fb14578':
  vorbis: Check the vlc value in setup_classifs

Conflicts:
libavcodec/vorbisdec.c

See: ae038c0914460646503be083e30e3971093239a1
See: 709cae2bcbc0ea2c5d46c932b3d8301cf8f98e6b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/vorbisdec.c

@@@ -1329,30 -1316,21 +1329,25 @@@ static av_always_inline int setup_class
  
              av_dlog(NULL, "Classword: %u\n", temp);
  
-             if ((int)temp < 0)
-                 return temp;
++            av_assert0(temp < 65536);
 +
-             av_assert0(vr->classifications > 1); //needed for inverse[]
+             if (temp < 0) {
+                 av_log(vc->avctx, AV_LOG_ERROR,
+                        "Invalid vlc code decoding %d channel.", j);
+                 return AVERROR_INVALIDDATA;
+             }
  
-             if (temp <= 65536) {
-                 for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
-                     temp2 = (((uint64_t)temp) * inverse_class) >> 32;
++            av_assert0(vr->classifications > 1); //needed for inverse[]
 +
-                     if (i < ptns_to_read)
-                         vr->classifs[p + i] = temp - temp2 * vr->classifications;
-                     temp = temp2;
-                 }
-             } else {
-                 for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
-                     temp2 = temp / vr->classifications;
+             for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
+                 temp2 = (((uint64_t)temp) * inverse_class) >> 32;
  
-                     if (i < ptns_to_read)
-                         vr->classifs[p + i] = temp - temp2 * vr->classifications;
-                     temp = temp2;
-                 }
 -                if (i < vr->ptns_to_read)
++                if (i < ptns_to_read)
+                     vr->classifs[p + i] = temp - temp2 * vr->classifications;
+                 temp = temp2;
              }
          }
 -        p += vr->ptns_to_read;
 +        p += ptns_to_read;
      }
      return 0;
  }
@@@ -1405,8 -1377,8 +1400,8 @@@ static av_always_inline int vorbis_resi
          voffset = vr->begin;
          for (partition_count = 0; partition_count < ptns_to_read;) {  // SPEC        error
              if (!pass) {
-                 int ret;
-                 if ((ret = setup_classifs(vc, vr, do_not_decode, ch_used, partition_count, ptns_to_read)) < 0)
 -                int ret = setup_classifs(vc, vr, do_not_decode, ch_used, partition_count);
++                int ret = setup_classifs(vc, vr, do_not_decode, ch_used, partition_count, ptns_to_read);
+                 if (ret < 0)
                      return ret;
              }
              for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) {