opusfile icon indicating copy to clipboard operation
opusfile copied to clipboard

http: Avoid undefined behavior in va_arg conversion

Open daddesio opened this issue 2 years ago • 0 comments

Compiling under Clang 13 with -Wextra resulted in the following warning:

src/http.c:3470:31: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
    request=va_arg(_ap,char *)-(char *)NULL;

It seems subtracting a null pointer is undefined behavior, which we can avoid by casting to intptr_t instead.

Request macros (e.g. OP_GET_SERVER_INFO) already do a simple cast ((char*)_request) rather than addition with null pointer (_request+(char*)NULL) so nothing needs to be changed on that end.

daddesio avatar Jul 06 '22 01:07 daddesio