From 00c190aeed65eeef235bd502434ed36c23aa932b Mon Sep 17 00:00:00 2001 From: alesapin Date: Fri, 27 Nov 2020 14:57:48 +0300 Subject: [PATCH] Fix unitialized memory --- src/Server/TestKeeperTCPHandler.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Server/TestKeeperTCPHandler.cpp b/src/Server/TestKeeperTCPHandler.cpp index 9343ada2c55..fff6c344b4e 100644 --- a/src/Server/TestKeeperTCPHandler.cpp +++ b/src/Server/TestKeeperTCPHandler.cpp @@ -163,12 +163,15 @@ struct SocketInterruptablePollWrapper { UInt8 byte; read_result = read(pipe.fds_rw[0], &byte, sizeof(byte)); - if (byte == WATCH_RESPONSE_BYTE) - result |= HAS_WATCH_RESPONSE; - else if (byte == RESPONSE_BYTE) - result |= HAS_RESPONSE; - else - throw Exception("Unexpected byte received from signaling pipe", ErrorCodes::UNEXPECTED_PACKET_FROM_CLIENT); + if (read_result > 0) + { + if (byte == WATCH_RESPONSE_BYTE) + result |= HAS_WATCH_RESPONSE; + else if (byte == RESPONSE_BYTE) + result |= HAS_RESPONSE; + else + throw Exception("Unexpected byte received from signaling pipe", ErrorCodes::UNEXPECTED_PACKET_FROM_CLIENT); + } } while (read_result > 0 || (read_result < 0 && errno == EINTR));