Skip to content

Commit 5eb65b1

Browse files
committed
http: Avoid undefined behavior in va_arg conversion
Subtracting a null pointer is undefined behavior according to Clang 13 (-Wnull-pointer-subtraction). Avoid this 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.
1 parent cf218fb commit 5eb65b1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/http.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,10 +3466,12 @@ static void *op_url_stream_vcreate_impl(OpusFileCallbacks *_cb,
34663466
pinfo=NULL;
34673467
*_pinfo=NULL;
34683468
for(;;){
3469-
ptrdiff_t request;
3470-
request=va_arg(_ap,char *)-(char *)NULL;
3469+
char *prequest;
3470+
intptr_t request;
3471+
prequest=va_arg(_ap,char *);
34713472
/*If we hit NULL, we're done processing options.*/
3472-
if(!request)break;
3473+
if(!prequest)break;
3474+
request=(intptr_t)prequest;
34733475
switch(request){
34743476
case OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST:{
34753477
skip_certificate_check=!!va_arg(_ap,opus_int32);

0 commit comments

Comments
 (0)