Skip to content

Commit

Permalink
jbuf: fix possible division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed May 18, 2023
1 parent c659b59 commit 2e932b5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/jbuf/jbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ static void calc_rdiff(struct jbuf *jb, uint16_t seq)
int32_t rdiff;
int32_t adiff;
int32_t s; /**< EMA coefficient */
uint32_t fpr = 1; /**< Frame packet ration */
uint32_t wish;
uint32_t max = jb->max;
bool down = false;
Expand All @@ -263,9 +264,11 @@ static void calc_rdiff(struct jbuf *jb, uint16_t seq)
if (!jb->seq_get)
return;

uint32_t fpr = jb->n / jb->nf; /* frame packet ratio */
if (!fpr)
fpr = 1;
if (jb->nf) {
fpr = jb->n / jb->nf;
if (!fpr)
fpr = 1;
}

max = max / fpr;

Expand Down

0 comments on commit 2e932b5

Please sign in to comment.