Add some toxav bounds/sanity checks

This commit is contained in:
jfreegman 2022-01-31 14:14:23 -05:00
parent 95d0f5ccbe
commit da4ef6481e
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 5 additions and 11 deletions

View File

@ -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);
@ -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;
}
@ -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;
}
}

View File

@ -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