<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40209 >

Marko Lindqvist wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=40209 >
> 
> On 21/04/2008, Elmo Todurov  wrote:
>>  Now I want a cookie!
>>  $ svn diff
>>  Index: server/sernet.c
>>  ===================================================================
>>  --- server/sernet.c     (revision 14605)
>>  +++ server/sernet.c     (working copy)
>>  @@ -185,6 +185,7 @@
>>    line_internal = local_to_internal_string_malloc(line);
>>    (void) handle_stdin_input(NULL, line_internal, FALSE);
>>    free(line_internal);
>>  +  free(line);
>>
>>    readline_handled_input = TRUE;
>>   }
> 
>  Are you sure about this? Does readline really expect callback to free
> the line? (and if it does, can it be bug in the specific readline
> version you are using?)

Yeah it seems correct.  I've been seeing this leak in valgrind for a 
long time but never realized the free call had to go in that particular 
callback function.  Adding it there removes the warning.

==1040== 13 bytes in 1 blocks are definitely lost in loss record 1 of 17
==1040==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==1040==    by 0x405BC21: xmalloc (in /lib/libreadline.so.5.2)
==1040==    by 0x4044109: readline_internal_teardown (in 
/lib/libreadline.so.5.2)
==1040==    by 0x4057867: rl_callback_read_char (in /lib/libreadline.so.5.2)
==1040==    by 0x80FE355: server_sniff_all_input (sernet.c:691)
==1040==    by 0x80B5B84: srv_main (srv_main.c:2201)
==1040==    by 0x804ABEE: main (civserver.c:267)

-jason



_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to