Fix of undefined behavior of null referencing (#10016)

Motivation:

Current code depends on some "undefined behaviour".

Modification:

Fix of undefined behavior of null referencing

Result:

Correct c code.
This commit is contained in:
Vitaly Buka 2020-02-11 00:56:51 -08:00 committed by Norman Maurer
parent 7e156b1e62
commit df4fd115df
1 changed files with 2 additions and 1 deletions

View File

@ -16,6 +16,7 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -50,7 +51,7 @@ extern int accept4(int sockFd, struct sockaddr* addr, socklen_t* addrlen, int fl
// macro to calculate the length of a sockaddr_un struct for a given path length.
// see sys/un.h#SUN_LEN, this is modified to allow nul bytes
#define _UNIX_ADDR_LENGTH(path_len) (uintptr_t) (((struct sockaddr_un *) 0)->sun_path) + path_len
#define _UNIX_ADDR_LENGTH(path_len) ((uintptr_t) offsetof(struct sockaddr_un, sun_path) + (uintptr_t) path_len)
static int nettyNonBlockingSocket(int domain, int type, int protocol) {
#ifdef SOCK_NONBLOCK