net/icmp/icmp_recvfrom.c: fix a NULL dereference

Found by clang-check:

icmp/icmp_recvfrom.c:374:30: warning: Dereference of null pointer (loaded from variable 'fromlen')
      if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in))
                             ^~~~~~~~
1 warning generated.
This commit is contained in:
YAMAMOTO Takashi 2020-07-30 16:41:31 +09:00 committed by Alin Jerpelea
parent 1078210f7f
commit bf9ba474a5
1 changed files with 1 additions and 1 deletions

View File

@ -371,7 +371,7 @@ ssize_t icmp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
if (from != NULL) if (from != NULL)
{ {
if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in)) if (fromlen == NULL || *fromlen < sizeof(struct sockaddr_in))
{ {
return -EINVAL; return -EINVAL;
} }