This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: stream: don't crash in _close() when fd is not initialized ...................................................................... stream: don't crash in _close() when fd is not initialized We use the magic value '-1' in case the file descriptor is not yet initialized. If somebody calls osmo_stream_*_close() before this changes, we used to crash. Let's check for this and avoid a crash. Also, after close let's change the fd to -1 again to mark the fd invalidity. Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868 --- M src/stream.c 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/stream.c b/src/stream.c index d72d800..93de3b7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -101,8 +101,11 @@ void osmo_stream_cli_close(struct osmo_stream_cli *cli) { + if (cli->ofd.fd == -1) + return; osmo_fd_unregister(&cli->ofd); close(cli->ofd.fd); + cli->ofd.fd = -1; } static void osmo_stream_cli_read(struct osmo_stream_cli *cli) @@ -506,8 +509,11 @@ void osmo_stream_srv_link_close(struct osmo_stream_srv_link *link) { + if (link->ofd.fd == -1) + return; osmo_fd_unregister(&link->ofd); close(link->ofd.fd); + link->ofd.fd = -1; } struct osmo_stream_srv { -- To view, visit https://gerrit.osmocom.org/2111 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder