]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server/sockfilt: check for NULL `tv` to silence clang-tidy
authorViktor Szakats <commit@vsz.me>
Thu, 19 Feb 2026 17:34:35 +0000 (18:34 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 20 Feb 2026 11:08:52 +0000 (12:08 +0100)
A NULL dereference cannot happen with existing use of this code.

linux-mingw, CM clang-tidy:
```
/home/runner/work/curl/curl/tests/server/sockfilt.c:720:24: error: Access
 to field 'tv_sec' results in a dereference of a null pointer (loaded from
 variable 'tv') [clang-analyzer-core.NullDereference,-warnings-as-errors]
  720 |             tv->tv_sec = 0;
      |             ~~         ^
```
Ref: https://github.com/curl/curl/actions/runs/22191200093/job/64179197235?pr=20631#step:10:283

Cherry-picked from #20631

Closes #20639

tests/server/sockfilt.c

index 6bdd5633b1cc919bf6017832897644a39f39b2b1..42a4ad1079fd917dce46bb7222e4d04db0ae226c 100644 (file)
@@ -717,8 +717,10 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
             data[nws].wsasock = wsasock;
             data[nws].wsaevent = wsaevent;
             data[nfd].wsastate = 0;
-            tv->tv_sec = 0;
-            tv->tv_usec = 0;
+            if(tv) {
+              tv->tv_sec = 0;
+              tv->tv_usec = 0;
+            }
             /* check if the socket is already ready */
             if(select(fd + 1, &readsock, &writesock, &exceptsock, tv) == 1) {
               logmsg("[select_ws] socket %d is ready", fd);