[PATCH] libosmo-netif[master]: stream: don't crash in _close() when fd is not initialized

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.org
Thu Mar 16 23:24:29 UTC 2017


Review at  https://gerrit.osmocom.org/2111

stream: don't crash in _close() when fd is not initialized

Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868
---
M src/stream.c
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/11/2111/1

diff --git a/src/stream.c b/src/stream.c
index d72d800..de00f52 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -101,6 +101,8 @@
 
 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);
 }
@@ -506,6 +508,8 @@
 
 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);
 }

-- 
To view, visit https://gerrit.osmocom.org/2111
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list