Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94de222f authored by Antoine Soulier's avatar Antoine Soulier Committed by Jakub Pawlowski
Browse files

fix: Crash when forward stream writes over backward one

Test: run liblc3_fuzzer
Bug: 221572680
Change-Id: I7643b534d2ea39354a9a7f3d9b6463578ab4a6c7
parent 250aab36
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -139,7 +139,8 @@ int lc3_check_bits(const struct lc3_bits *bits)
static inline void accu_flush(
static inline void accu_flush(
    struct lc3_bits_accu *accu, struct lc3_bits_buffer *buffer)
    struct lc3_bits_accu *accu, struct lc3_bits_buffer *buffer)
{
{
    int nbytes = LC3_MIN(accu->n >> 3, buffer->p_bw - buffer->p_fw);
    int nbytes = LC3_MIN(accu->n >> 3,
        LC3_MAX(buffer->p_bw - buffer->p_fw, 0));


    accu->n -= 8 * nbytes;
    accu->n -= 8 * nbytes;