shithub: aubio

Download patch

ref: 60314193c914cfbc84cde61faeec17c8c81876fd
parent: 2e137882a978b286d5aaff5f0f15aa5f22722919
author: Paul Brossier <piem@piem.org>
date: Wed Dec 12 18:25:35 EST 2018

[ci] avoid read out of bound in sink_vorbis_do_multi, simplify _open

--- a/src/io/sink_vorbis.c
+++ b/src/io/sink_vorbis.c
@@ -106,11 +106,7 @@
 {
   float quality_mode = .9;
 
-  if (s->samplerate == 0 || s->channels == 0)
-  {
-    AUBIO_ERR("sink_vorbis: vorbis_encode_init_vbr failed\n");
-    return AUBIO_FAIL;
-  }
+  if (s->samplerate == 0 || s->channels == 0) return AUBIO_FAIL;
 
   s->fid = fopen((const char *)s->path, "wb");
   if (!s->fid) return AUBIO_FAIL;
@@ -247,6 +243,7 @@
     uint_t write)
 {
   uint_t c, v;
+  uint_t channels = MIN(s->channels, write_data->height);
   float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
   // fill buffer
   if (!write) {
@@ -255,7 +252,7 @@
     AUBIO_WRN("sink_vorbis: failed fetching buffer of size %d\n", write);
     return;
   } else {
-    for (c = 0; c < s->channels; c++) {
+    for (c = 0; c < channels; c++) {
       for (v = 0; v < write; v++) {
         buffer[c][v] = write_data->data[c][v];
       }