[tor-commits] [tor/master] Address coverity warnings (CID 1439133/1439132).

nickm at torproject.org nickm at torproject.org
Tue Sep 11 16:23:27 UTC 2018


commit 34a2cbb249cdaf23c88b93972a9216926a8d7551
Author: George Kadianakis <desnacked at riseup.net>
Date:   Mon Sep 10 16:47:28 2018 +0300

    Address coverity warnings (CID 1439133/1439132).
    
    >>>>    CID 1439133:  Null pointer dereferences  (REVERSE_INULL)
    >>>>    Null-checking "fields" suggests that it may be null, but it
    >>>> has already been dereferenced on all paths leading to the check.
    
    >>>>    CID 1439132:  Null pointer dereferences  (REVERSE_INULL)
    >>>>    Null-checking "fields" suggests that it may be null, but it
    >>>> has already been dereferenced on all paths leading to the check.
---
 src/feature/hs/hs_client.c  | 7 +++----
 src/feature/hs/hs_service.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c
index 6f031eb3b..a6384b87a 100644
--- a/src/feature/hs/hs_client.c
+++ b/src/feature/hs/hs_client.c
@@ -1524,10 +1524,9 @@ parse_auth_file_content(const char *client_key_str)
   if (seckey_b32) {
     memwipe(seckey_b32, 0, strlen(seckey_b32));
   }
-  if (fields) {
-    SMARTLIST_FOREACH(fields, char *, s, tor_free(s));
-    smartlist_free(fields);
-  }
+  tor_assert(fields);
+  SMARTLIST_FOREACH(fields, char *, s, tor_free(s));
+  smartlist_free(fields);
   return auth;
 }
 
diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c
index 43e5626a5..30d23eb77 100644
--- a/src/feature/hs/hs_service.c
+++ b/src/feature/hs/hs_service.c
@@ -1192,10 +1192,9 @@ parse_authorized_client(const char *client_key_str)
   if (pubkey_b32) {
     memwipe(pubkey_b32, 0, strlen(pubkey_b32));
   }
-  if (fields) {
-    SMARTLIST_FOREACH(fields, char *, s, tor_free(s));
-    smartlist_free(fields);
-  }
+  tor_assert(fields);
+  SMARTLIST_FOREACH(fields, char *, s, tor_free(s));
+  smartlist_free(fields);
   return client;
 }
 





More information about the tor-commits mailing list