]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
asyn-thread: fix cppcheck warning
authorJay Satiro <raysatiro@yahoo.com>
Sat, 2 May 2020 18:53:09 +0000 (14:53 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Sat, 2 May 2020 19:03:39 +0000 (15:03 -0400)
- Check for NULL entry parameter before attempting to deref entry in
  Curl_resolver_is_resolved, like is already done in asyn-ares.

This is to silence cppcheck which does not seem to understand that
asyn-ares and asyn-thread have separate Curl_resolver_is_resolved
and those units are mutually exclusive. Prior to this change it warned
of a scenario where asyn-thread's Curl_resolver_is_resolved is called
with a NULL entry from asyn-ares, but that couldn't happen.

Reported-by: rl1987@users.noreply.github.com
Fixes https://github.com/curl/curl/issues/5326

lib/asyn-thread.c

index 68dcbb3ecd7635d1fbe9d8a225aba95914dada58..6f63ce833351205a21af4c3086a922da3f98a30b 100644 (file)
@@ -593,7 +593,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
   struct thread_data   *td = (struct thread_data*) conn->async.os_specific;
   int done = 0;
 
-  *entry = NULL;
+  if(entry)
+    *entry = NULL;
 
   if(!td) {
     DEBUGASSERT(td);
@@ -613,7 +614,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
       return result;
     }
     destroy_async_data(&conn->async);
-    *entry = conn->async.dns;
+    if(entry)
+      *entry = conn->async.dns;
   }
   else {
     /* poll for name lookup done with exponential backoff up to 250ms */