osmo_stream_{cli,srv}_destroy: fix mem leak: empty msgb queue

On destroying a client or server stream, deallocate any msgbs that are still
pending in the queue.

In libosmo-sccp, the ss7_test.c in test_as(), messages are queued and were,
before this, left floating after the stream was destroyed, causing a sanitizer
memory leak. This patch fixes the leak.

Depends: Ia291832ca445d4071f0ed9a01730d945ff691cf7 (libosmocore)
Change-Id: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639
This commit is contained in:
Neels Hofmeyr 2017-11-17 03:29:51 +01:00 committed by Neels Hofmeyr
parent b6e8d39417
commit c72be77aa3
1 changed files with 2 additions and 0 deletions

View File

@ -430,6 +430,7 @@ void osmo_stream_cli_destroy(struct osmo_stream_cli *cli)
{
osmo_stream_cli_close(cli);
osmo_timer_del(&cli->timer);
msgb_queue_free(&cli->tx_queue);
talloc_free(cli);
}
@ -924,6 +925,7 @@ void osmo_stream_srv_destroy(struct osmo_stream_srv *conn)
osmo_fd_unregister(&conn->ofd);
if (conn->closed_cb)
conn->closed_cb(conn);
msgb_queue_free(&conn->tx_queue);
talloc_free(conn);
}