diff --git a/libcelt/celt.c b/libcelt/celt.c index f8c45e59..1279e8a3 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -825,7 +825,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i int silence=0; SAVE_STACK; - if (nbCompressedBytes<0 || pcm==NULL) + if (nbCompressedBytes<2 || pcm==NULL) return CELT_BAD_ARG; for (LM=0;LM<4;LM++) @@ -924,13 +924,16 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i CELT_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+st->overlap)+st->overlap, N); } while (++c0) { - effectiveBytes=nbCompressedBytes=nbFilledBytes+2; + effectiveBytes=nbCompressedBytes=IMIN(nbCompressedBytes, nbFilledBytes+2); total_bits=nbCompressedBytes*8; nbAvailableBytes=2; ec_byte_shrink(&buf, nbCompressedBytes); @@ -2019,7 +2022,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da X[c*N+i] = 0; while (++c