* #27201: libiax: don't pass out of bounds pointer to memmove (minbuf)

This commit is contained in:
Tristan Matthews
2013-07-12 10:17:14 -04:00
parent 4a33c93ed8
commit 0b00589a16

View File

@ -256,8 +256,10 @@ static void history_calc_maxbuf(jitterbuf *jb)
for (j=0;j<JB_HISTORY_MAXBUF_SZ;j++) {
/* found where it fits */
if (toins < jb->hist_minbuf[j]) {
/* move over */
memmove(jb->hist_minbuf + j + 1, jb->hist_minbuf + j, (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_minbuf[0]));
/* move over if there's space */
const size_t slide = (JB_HISTORY_MAXBUF_SZ - (j + 1)) * sizeof(jb->hist_minbuf[0]);
if (slide > 0)
memmove(jb->hist_minbuf + j + 1, jb->hist_minbuf + j, slide);
/* insert */
jb->hist_minbuf[j] = toins;