diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-10-01 21:36:09 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-10-01 21:36:09 +0200 |
commit | f066b0aa840f5c9c95185d6da39702e1084dc2ff (patch) | |
tree | c1bcac8dc8938fe4f45ec61dad95da3880ac74b4 /src | |
parent | 08e121571ba3e16efbf2ead1d7e10075b7e00cea (diff) | |
download | ODR-AudioEnc-f066b0aa840f5c9c95185d6da39702e1084dc2ff.tar.gz ODR-AudioEnc-f066b0aa840f5c9c95185d6da39702e1084dc2ff.tar.bz2 ODR-AudioEnc-f066b0aa840f5c9c95185d6da39702e1084dc2ff.zip |
Fix crash with bitrates above 144kbps
The output buffer was not allocated big enough.
Diffstat (limited to 'src')
-rw-r--r-- | src/dabplus-enc.cpp | 8 | ||||
-rw-r--r-- | src/utils.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index dfca4f1..e9aea14 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -376,7 +376,7 @@ int main(int argc, char *argv[]) } if (subchannel_index < 1 || subchannel_index > 24) { - fprintf(stderr, "Bad subchannels number: %d, try other bitrate.\n", + fprintf(stderr, "Bad subchannel index: %d, must be between 1 and 24. Try other bitrate.\n", subchannel_index); return 1; } @@ -534,10 +534,10 @@ int main(int argc, char *argv[]) } int outbuf_size = subchannel_index*120; - uint8_t zmqframebuf[2048]; + uint8_t zmqframebuf[ZMQ_HEADER_SIZE + 24*120]; zmq_frame_header_t *zmq_frame_header = (zmq_frame_header_t*)zmqframebuf; - uint8_t outbuf[2048]; + uint8_t outbuf[24*120]; if(outbuf_size % 5 != 0) { fprintf(stderr, "(outbuf_size mod 5) = %d\n", outbuf_size % 5); @@ -755,6 +755,8 @@ int main(int argc, char *argv[]) zmq_frame_header->audiolevel_left = peak_left; zmq_frame_header->audiolevel_right = peak_right; + assert(ZMQ_FRAME_SIZE(zmq_frame_header) <= NUMOF(zmqframebuf)); + memcpy(ZMQ_FRAME_DATA(zmq_frame_header), outbuf, outbuf_size); diff --git a/src/utils.h b/src/utils.h index a5aaf8c..7cd9a96 100644 --- a/src/utils.h +++ b/src/utils.h @@ -36,6 +36,8 @@ struct zmq_frame_header_t #define ZMQ_ENCODER_FDK 1 +#define ZMQ_HEADER_SIZE sizeof(struct zmq_frame_header_t) + /* The expected frame size incl data of the given frame */ #define ZMQ_FRAME_SIZE(f) (sizeof(struct zmq_frame_header_t) + f->datasize) |