ldb: Avoid a possible NULL pointer dereference
authorAndreas Schneider <asn@samba.org>
Thu, 5 Dec 2019 16:02:39 +0000 (17:02 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 6 Dec 2019 09:12:26 +0000 (09:12 +0000)
Found by cppcheck.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
lib/ldb/ldb_key_value/ldb_kv_index.c

index 0853b28fe400fe5ac97146840ad07d048950e3e9..059abef67489e40e41f0f9652e5683c51a3b7bd0 100644 (file)
@@ -1175,7 +1175,7 @@ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb,
                }
        }
 
-       if (v.data != value->data && !empty_val) {
+       if (value != NULL && v.data != value->data && !empty_val) {
                talloc_free(v.data);
        }
        talloc_free(attr_folded);