From e5abc312ec38555a635505d68e101094c5490b72 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Sun, 18 Mar 2018 03:32:19 +0100 Subject: [PATCH] lib-program-client: test-program-client-unix: Further fix error handling in test_program_input(). --- src/lib-program-client/test-program-client-unix.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib-program-client/test-program-client-unix.c b/src/lib-program-client/test-program-client-unix.c index c06023064d..386bfd48ff 100644 --- a/src/lib-program-client/test-program-client-unix.c +++ b/src/lib-program-client/test-program-client-unix.c @@ -159,21 +159,25 @@ static void test_program_input(struct test_client *client) const char *line = ""; int ret = 0; - for (;;) { + while (ret >= 0) { if (client->state == CLIENT_STATE_BODY) { ret = test_program_input_handle(client, NULL); break; } - while (client->state != CLIENT_STATE_BODY && - (line=i_stream_read_next_line(client->in)) != NULL) { - if (test_program_input_handle(client, line) < 0) { + while (client->state < CLIENT_STATE_BODY) { + line = i_stream_read_next_line(client->in); + if (line == NULL) { + ret = 0; + break; + } + if ((ret=test_program_input_handle(client, line)) < 0) { i_warning("Client sent invalid line: %s", line); break; } } } - if (ret < 0) + if (ret < 0 || client->in->stream_errno != 0) return; if (!client->in->eof) return; -- 2.47.3