From 1ed61b3a9c4b87e9cf7d50eeeb1d1de92d718c93 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 25 Mar 2001 19:30:28 +0000 Subject: [PATCH] Fix unportable assumptions about alignment of local char[n] variables. --- src/interfaces/odbc/socket.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c index c4d0a1bec8..f8783197ec 100644 --- a/src/interfaces/odbc/socket.c +++ b/src/interfaces/odbc/socket.c @@ -227,23 +227,29 @@ SOCK_put_string(SocketClass *self, char *string) int SOCK_get_int(SocketClass *self, short len) { - char buf[4]; - switch (len) { case 2: - SOCK_get_n_char(self, buf, len); + { + unsigned short buf; + + SOCK_get_n_char(self, (char *) &buf, len); if (self->reverse) - return *((unsigned short *) buf); + return buf; else - return ntohs(*((unsigned short *) buf)); + return ntohs(buf); + } case 4: - SOCK_get_n_char(self, buf, len); + { + unsigned int buf; + + SOCK_get_n_char(self, (char *) &buf, len); if (self->reverse) - return *((unsigned int *) buf); + return buf; else - return ntohl(*((unsigned int *) buf)); + return ntohl(buf); + } default: self->errornumber = SOCKET_GET_INT_WRONG_LENGTH; -- 2.40.0