wiechu/ekg2 — pull request #1 by hiciu (2013-08-09 14:55:42+00:00)
Title: fix null pointer dereference

Hej,

Dostałem SIGSEGV po /quit. Tutaj mam wyjście z gdb:
```
Core was generated by `ekg2'.
Program terminated with signal 11, Segmentation fault.
#0 0x000000000041c9b0 in ekg2_conneciton_set_error (cd=cd@entry=0x1a54180, err=err@entry=0x7fff9099b6c8, format=0x443812 "Error sending to socket: ") at ekg/connections.c:237
237 debug_error("%s\n", cd->error->message);
(gdb) print cd->error
$1 = (GError *) 0x0
(gdb) bt
#0 0x000000000041c9b0 in ekg2_conneciton_set_error (cd=cd@entry=0x1a54180, err=err@entry=0x7fff9099b6c8, format=0x443812 "Error sending to socket: ") at ekg/connections.c:237
#1 0x000000000041d38b in ekg2_connection_write (cd=0x1a54180, buffer=buffer@entry=0x1d94ad0, length=16) at ekg/connections.c:268
#2 0x00007f48f12c8b01 in jabber_write (session=session@entry=0x12f1180, format=format@entry=0x7f48f12c97b9 "") at plugins/jabber/misc.c:31
#3 0x00007f48f12b4e92 in jabber_command_disconnect (name=0x7f48f12c9ec8 "disconnect", params=0x1e1c310, session=0x12f1180, target=, quiet=) at plugins/jabber/commands.c:121
#4 0x00000000004155cf in command_exec (target=target@entry=0x0, session=, session@entry=0x12f1180, xline=xline@entry=0x44286c "/disconnect", quiet=quiet@entry=3) at ekg/commands.c:2683
#5 0x00000000004162e3 in cmd_quit (name=, params=0x1e22ec0, session=, target=, quiet=) at ekg/commands.c:1758
#6 0x00000000004155cf in command_exec (target=0x154f210 "#conf1", session=, xline=xline@entry=0x1e21040 "/quit", quiet=quiet@entry=0) at ekg/commands.c:2683
#7 0x00007f48efc663cf in binding_accept_line (arg=) at plugins/ncurses/bindings.c:281
#8 0x00007f48efc6ae6d in ncurses_watch_stdin (type=, fd=0, watch=WATCH_READ, data=) at plugins/ncurses/input.c:688
#9 0x000000000042e4e8 in watch_handle (w=0xfff3b0) at ekg/sources.c:1411
#10 watch_old_wrapper (f=, cond=G_IO_IN, data=0xfff3b0) at ekg/sources.c:1426
#11 0x00007f48f3ae9da6 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#12 0x00007f48f3aea0f8 in ?? () from /usr/lib/libglib-2.0.so.0
#13 0x00007f48f3aea19c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#14 0x000000000040ebbc in main (argc=1, argv=0x7fff9099bce8) at ekg/ekg.c:795
(gdb) up
#1 0x000000000041d38b in ekg2_connection_write (cd=0x1a54180, buffer=buffer@entry=0x1d94ad0, length=16) at ekg/connections.c:268
268 ekg2_conneciton_set_error(cd, &error, _("Error sending to socket: "));
(gdb) print *cd
$4 = {error = 0x0, sess_id = 0xfadc80 "xmpp:xxx@chat.facebook.com", watch_id = 0, tls = 0, socket = 0x0, conn = 0x0, channel = 0x0, in_stream = 0x0, out_stream = 0x0, in_buf = 0x1299ea0, use_out_buf = 0, out_buf = 0x1299ee0,
input_callback = 0x7f48f12bb860 , failure_callback = 0x41c860 , disconnect_handler = 0x7f48f12bb760 , cs = 0x1a5a460}
```

(mam też plik core, ale nie chcę go udostępniać jeśli to możliwe).

Wartość ```error``` w ```ekg2_conneciton_set_error``` pochodzi z ```g_output_stream_write```. Wygląda na to, że ```g_output_stream_write``` zwróciło -1 i jednocześnie nie ustawiło nic pod ```error```.

Prawdziwa przyczyna jest pewnie w innym miejscu: ta sesja była połączona z facebookiem, facebook zrywa połączenia po jakimś czasie i sesja sobie wisi w takim dziwnym stanie niepodłączona.