Skip to content

Commit

Permalink
Add some toxav bounds/sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Jan 31, 2022
1 parent 95d0f5c commit da4ef64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions toxav/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void ac_iterate(ACSession *ac)
}

#endif

assert(msg->len > 4);

/* Pick up sampling rate from packet */
memcpy(&ac->lp_sampling_rate, msg->data, 4);
Expand Down Expand Up @@ -210,10 +210,7 @@ void ac_iterate(ACSession *ac)
int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg)
{
if (!acp || !msg) {
if (msg) {
free(msg);
}

free(msg);
return -1;
}

Expand Down Expand Up @@ -295,11 +292,8 @@ static struct JitterBuffer *jbuf_new(uint32_t capacity)
static void jbuf_clear(struct JitterBuffer *q)
{
while (q->bottom != q->top) {
if (q->queue[q->bottom % q->size]) {
free(q->queue[q->bottom % q->size]);
q->queue[q->bottom % q->size] = nullptr;
}

free(q->queue[q->bottom % q->size]);
q->queue[q->bottom % q->size] = nullptr;
++q->bottom;
}
}
Expand Down
2 changes: 1 addition & 1 deletion toxav/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static struct RTPMessage *process_frame(const Logger *log, struct RTPWorkBufferL
struct RTPMessage *const m_new = slot->buf;
slot->buf = nullptr;

assert(wkbl->next_free_entry >= 1);
assert(wkbl->next_free_entry >= 1 && wkbl->next_free_entry <= USED_RTP_WORKBUFFER_COUNT);

if (slot_id != wkbl->next_free_entry - 1) {
// The slot is not the last slot, so we created a gap. We move all the
Expand Down

0 comments on commit da4ef64

Please sign in to comment.