CID 1452109: dsdb/util: do not check for NULL after deref
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 30 Jul 2019 22:16:37 +0000 (10:16 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 Jul 2019 02:50:24 +0000 (02:50 +0000)
This is all strictly unnecessary, as ret is always != LDB_SUCCESS when
res is NULL, but we want to make peace between clang and converity.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/common/util.c

index 51d6b243347fa290e13d7f268407bd71430202ea..1c71c243ed5cec52a690ef9c25327a6624e5e78b 100644 (file)
@@ -3582,18 +3582,12 @@ int samdb_dns_host_name(struct ldb_context *sam_ctx, const char **host_name)
 
        ret = dsdb_search_dn(sam_ctx, tmp_ctx, &res, NULL, attrs, 0);
 
-       if (res->count != 1 || ret != LDB_SUCCESS) {
+       if (res == NULL || res->count != 1 || ret != LDB_SUCCESS) {
                DEBUG(0, ("Failed to get rootDSE for dnsHostName: %s",
                          ldb_errstring(sam_ctx)));
                TALLOC_FREE(tmp_ctx);
                return ret;
        }
-       /* satisfy clang */
-       if (res == NULL) {
-               TALLOC_FREE(tmp_ctx);
-               return LDB_ERR_OTHER;
-       }
-
 
        _host_name = ldb_msg_find_attr_as_string(res->msgs[0],
                                                 "dnsHostName",