comparison libpurple/circbuffer.c @ 26195:bcbc5994d21c

Josef Andrysek noticed that there's a scenario where the PurpleCircBuffer gets corrupted and supplied a patch to fix it. Fixes #8706
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 20 Mar 2009 02:42:38 +0000
parents 584063555949
children 01f1929d0936
comparison
equal deleted inserted replaced
26194:c884b702ec17 26195:bcbc5994d21c
66 buf->outptr = buf->buffer + out_offset; 66 buf->outptr = buf->buffer + out_offset;
67 } 67 }
68 68
69 /* If the fill pointer is wrapped to before the remove 69 /* If the fill pointer is wrapped to before the remove
70 * pointer, we need to shift the data */ 70 * pointer, we need to shift the data */
71 if (in_offset < out_offset) { 71 if (in_offset < out_offset
72 || (in_offset == out_offset && buf->bufused > 0)) {
72 int shift_n = MIN(buf->buflen - start_buflen, 73 int shift_n = MIN(buf->buflen - start_buflen,
73 in_offset); 74 in_offset);
74 memcpy(buf->buffer + start_buflen, buf->buffer, 75 memcpy(buf->buffer + start_buflen, buf->buffer,
75 shift_n); 76 shift_n);
76 77