From df52479eb4ade1cc4379d7e2f0fed8364d851bd3 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Sat, 15 Feb 2020 03:42:51 +0400 Subject: [PATCH] [apr] scan-build: Fix dereference of a null pointer and unused variable in network_io/unix --- libs/apr/network_io/unix/sendrecv.c | 3 +++ libs/apr/network_io/unix/sockets.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/apr/network_io/unix/sendrecv.c b/libs/apr/network_io/unix/sendrecv.c index 9ebc3cf3b4..f09a8fdf09 100644 --- a/libs/apr/network_io/unix/sendrecv.c +++ b/libs/apr/network_io/unix/sendrecv.c @@ -27,6 +27,8 @@ #include #endif +#include /* assert() */ + apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len) { @@ -287,6 +289,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, /* Ignore flags for now. */ flags = 0; + assert(flags=0); if (hdtr->numheaders > 0) { apr_size_t hdrbytes; diff --git a/libs/apr/network_io/unix/sockets.c b/libs/apr/network_io/unix/sockets.c index 4cff3bbca1..72dab7b89c 100644 --- a/libs/apr/network_io/unix/sockets.c +++ b/libs/apr/network_io/unix/sockets.c @@ -32,7 +32,11 @@ static apr_status_t socket_cleanup(void *sock) { apr_socket_t *thesocket = sock; - if (thesocket && thesocket->socketdes == -1) { + if (!thesocket) { + return APR_ENOTSOCK; + } + + if (thesocket->socketdes == -1) { return APR_SUCCESS; }