s4:kcc: Add a NULL check before qsort()
authorAndreas Schneider <asn@samba.org>
Mon, 24 Jul 2017 10:13:50 +0000 (12:13 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 24 Jul 2017 12:50:11 +0000 (14:50 +0200)
This fixes building with GCC 7.1.1

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source4/dsdb/kcc/kcc_topology.c

index cd4dcc554952e66553a55858a64f791fbf71757f..0e136ed79363a32ecdab3387d61a6ecd00a6eea6 100644 (file)
@@ -2445,6 +2445,10 @@ static NTSTATUS kcctpl_kruskal(TALLOC_CTX *mem_ctx, struct kcctpl_graph *graph,
        uint32_t i, num_expected_tree_edges, cst_edges;
        struct kcctpl_multi_edge_list output_edges;
 
+       if (internal_edges.data == NULL || internal_edges.count == 0) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
        num_expected_tree_edges = 0;
        for (i = 0; i < graph->vertices.count; i++) {
                struct kcctpl_vertex *vertex = &graph->vertices.data[i];