From d9eb5b75e3ee00c1b1add51e05d00e34a32253f5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 11 Feb 2001 23:46:40 +0000 Subject: [PATCH] SOCK_get_next_byte should not return garbage after error/EOF. Return zero bytes instead. --- src/interfaces/odbc/socket.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c index 131c466b0c..3c15eeecbb 100644 --- a/src/interfaces/odbc/socket.c +++ b/src/interfaces/odbc/socket.c @@ -286,7 +286,7 @@ SOCK_get_next_byte(SocketClass *self) { if (self->buffer_read_in >= self->buffer_filled_in) { - /* there are no more bytes left in the buffer -> */ + /* there are no more bytes left in the buffer, so */ /* reload the buffer */ self->buffer_read_in = 0; @@ -296,17 +296,19 @@ SOCK_get_next_byte(SocketClass *self) mylog("read %d, global_socket_buffersize=%d\n", self->buffer_filled_in, globals.socket_buffersize); - if (self->buffer_filled_in == -1) + if (self->buffer_filled_in < 0) { self->errornumber = SOCKET_READ_ERROR; self->errormsg = "Error while reading from the socket."; self->buffer_filled_in = 0; + return 0; } if (self->buffer_filled_in == 0) { self->errornumber = SOCKET_CLOSED; self->errormsg = "Socket has been closed."; self->buffer_filled_in = 0; + return 0; } } return self->buffer_in[self->buffer_read_in++]; -- 2.40.0