osmith has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/42866?usp=email )
Change subject: utils/gsmtap-logsend: close infile before exit ......................................................................
utils/gsmtap-logsend: close infile before exit
Related: SYS#8093 Change-Id: I259cf951c52f7d859475f5f79c803692c29fbec3 --- M utils/gsmtap-logsend.c 1 file changed, 10 insertions(+), 2 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
diff --git a/utils/gsmtap-logsend.c b/utils/gsmtap-logsend.c index 67114e7..9365362 100644 --- a/utils/gsmtap-logsend.c +++ b/utils/gsmtap-logsend.c @@ -50,6 +50,7 @@ FILE *infile; char *line; int rc; + int ret = 0;
while (1) { static const struct option long_options[] = { @@ -102,7 +103,8 @@ gsmtap_fd = gsmtap_source_init_fd(dest_host, dest_port); if (gsmtap_fd < 0) { fprintf(stderr, "Unable to create GSMTAP socket: %s\n", strerror(errno)); - exit(2); + ret = 2; + goto exit_close; }
/* prepare all the data structures that don't change for each line */ @@ -133,7 +135,13 @@ rc = writev(gsmtap_fd, iov, ARRAY_SIZE(iov)); if (rc <= 0) { fprintf(stderr, "Short write on GSMTAP socket: %d (%s)\n", rc, strerror(errno)); - exit(1); + ret = 1; + goto exit_close; } } + +exit_close: + if (infile != stdin) + fclose(infile); + exit(ret); }