diff 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
line wrap: on
line diff
--- a/libpurple/circbuffer.c	Wed Mar 18 19:30:16 2009 +0000
+++ b/libpurple/circbuffer.c	Fri Mar 20 02:42:38 2009 +0000
@@ -68,7 +68,8 @@
 
 	/* If the fill pointer is wrapped to before the remove
 	 * pointer, we need to shift the data */
-	if (in_offset < out_offset) {
+	if (in_offset < out_offset
+			|| (in_offset == out_offset && buf->bufused > 0)) {
 		int shift_n = MIN(buf->buflen - start_buflen,
 			in_offset);
 		memcpy(buf->buffer + start_buflen, buf->buffer,