From a5be8fe82c213ecdac71146a8029b6f51ec4db9d Mon Sep 17 00:00:00 2001 From: kieranm Date: Mon, 31 Mar 2003 09:34:56 +0000 Subject: [PATCH] Fixed bug in netconn_peer (test pcb for NULL before accessing) --- src/api/api_lib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 795d7c8a..e2d3e03d 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -301,12 +301,15 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr, case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: case NETCONN_UDP: - if ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0) - return -1; + if (conn->pcb.udp == NULL || + ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0)) + return ERR_CONN; *addr = (conn->pcb.udp->remote_ip); *port = conn->pcb.udp->remote_port; break; case NETCONN_TCP: + if(conn->pcb.tcp == NULL) + return ERR_CONN; *addr = (conn->pcb.tcp->remote_ip); *port = conn->pcb.tcp->remote_port; break;