[Pidgin] #8706: Crittical error in in circbuffer implementation

Pidgin trac at pidgin.im
Thu Mar 19 22:01:26 EDT 2009


#8706: Crittical error in in circbuffer implementation
------------------------+---------------------------------------------------
 Reporter:  ajosea      |           Owner:  datallah 
     Type:  defect      |          Status:  new      
Milestone:              |       Component:  libpurple
  Version:  2.5.5       |      Resolution:           
 Keywords:  circbuffer  |   Launchpad_bug:           
------------------------+---------------------------------------------------

Comment(by tmm1):

 {{{
 #include <stdlib.h>
 #include <stdio.h>
 #include <circbuffer.h>

 void debug_buf(PurpleCircBuffer *buf) {
   printf("{ buffer = %p \"%s\", len = %d, used = %d, inptr = %p \"%s\",
 outptr = %p \"%s\" }\n", buf->buffer, buf->buffer, (int)buf->buflen,
 (int)buf->bufused, buf->inptr, buf->inptr, buf->outptr, buf->outptr);
 }

 int main(){
   PurpleCircBuffer *buf = purple_circ_buffer_new(5);
   debug_buf(buf);
   purple_circ_buffer_append(buf, "hello", 5);
   debug_buf(buf);
   purple_circ_buffer_mark_read(buf, 3);
   debug_buf(buf);
   purple_circ_buffer_append(buf, "123", 3);
   debug_buf(buf);
   purple_circ_buffer_append(buf, "45678", 5);
   debug_buf(buf);
   purple_circ_buffer_destroy(buf);
   return 0;
 }
 }}}

 outputs:

 {{{
 { buffer = (nil) "(null)", len = 0, used = 0, inptr = (nil) "(null)",
 outptr = (nil) "(null)" }
 { buffer = 0x16db050 "hello", len = 5, used = 5, inptr = 0x16db055 "",
 outptr = 0x16db050 "hello" }
 { buffer = 0x16db050 "hello", len = 5, used = 2, inptr = 0x16db055 "",
 outptr = 0x16db053 "lo" }
 { buffer = 0x16db050 "123lo", len = 5, used = 5, inptr = 0x16db053 "lo",
 outptr = 0x16db053 "lo" }
 { buffer = 0x16db050 "12345678", len = 10, used = 10, inptr = 0x16db058
 "", outptr = 0x16db053 "45678" }
 }}}

 and after the patch:

 {{{
 { buffer = (nil) "(null)", len = 0, used = 0, inptr = (nil) "(null)",
 outptr = (nil) "(null)" }
 { buffer = 0xc26050 "hello", len = 5, used = 5, inptr = 0xc26055 "",
 outptr = 0xc26050 "hello" }
 { buffer = 0xc26050 "hello", len = 5, used = 2, inptr = 0xc26055 "",
 outptr = 0xc26053 "lo" }
 { buffer = 0xc26050 "123lo", len = 5, used = 5, inptr = 0xc26053 "lo",
 outptr = 0xc26053 "lo" }
 { buffer = 0xc26050 "678lo12345", len = 10, used = 10, inptr = 0xc26053
 "lo12345", outptr = 0xc26053 "lo12345" }
 }}}

-- 
Ticket URL: <http://developer.pidgin.im/ticket/8706#comment:2>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list