1
1

util: Fix graph allocation size

Fix an allocation bug that could occur on non-LP64 platforms.
match_edges_out is an array of integers representing the
edges of the graph (where vertices are ints), with two ints
for every edge.  The previous code allocated enough space
for num_dges * sizeof(int*), which happens to be the same
as num_edges * 2 * sizeof(int) on LP64 platforms, but would
be wrong on all other platforms.

Fixes: CID 1417754

Signed-off-by: Brian Barrett <bbarrett@amazon.com>
Этот коммит содержится в:
Brian Barrett 2017-09-17 19:49:26 +00:00
родитель 79f82f2c6d
Коммит abbe2ffb9f

Просмотреть файл

@ -914,7 +914,7 @@ int opal_bp_graph_solve_bipartite_assignment(const opal_bp_graph_t *g,
goto out;
}
*match_edges_out = malloc(*num_match_edges_out * sizeof(*match_edges_out));
*match_edges_out = malloc(*num_match_edges_out * 2 * sizeof(int));
if (NULL == *match_edges_out) {
*num_match_edges_out = 0;
OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE);