From ecb8e5255bdf3249a89e259f834b3b12c932fd5a Mon Sep 17 00:00:00 2001 From: Kazuho Oku <kazuhooku@gmail.com> Date: Mon, 27 Nov 2017 11:17:13 +0900 Subject: [PATCH] handle error;close file --- t/cli.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/cli.c b/t/cli.c index 34e5526c7..d676f8f12 100644 --- a/t/cli.c +++ b/t/cli.c @@ -151,7 +151,10 @@ static int handle_connection(int fd, ptls_context_t *ctx, const char *server_nam int inputfd = 0, maxfd = fd + 1; if (input_file != NULL) { - inputfd = open(input_file, O_RDONLY); + if ((inputfd = open(input_file, O_RDONLY)) == -1) { + fprintf(stderr, "failed to open file:%s:%s\n", input_file, strerror(errno)); + exit(1); + } if (inputfd >= maxfd) maxfd = inputfd + 1; } @@ -234,6 +237,8 @@ static int handle_connection(int fd, ptls_context_t *ctx, const char *server_nam Exit: ptls_buffer_dispose(&wbuf); ptls_free(tls); + if (input_file != NULL) + close(inputfd); return 0; }