From 4243cb7af0322ad2796909e530f87c473054de3c Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 11 Jan 2012 00:21:47 +0000 Subject: [PATCH] Bring over hwloc r4102 and r4104 for some upstream patches. This commit was SVN r25707. The following SVN revision numbers were found above: r4102 --> open-mpi/ompi@8961ca568dd347ad5d194ded35956c9e455059cb The following SVN revisions from the original message are invalid or inconsistent and therefore were not cross-referenced: r4104 --- opal/mca/hwloc/hwloc131/hwloc/src/topology.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opal/mca/hwloc/hwloc131/hwloc/src/topology.c b/opal/mca/hwloc/hwloc131/hwloc/src/topology.c index f53ac20710..b9704d19de 100644 --- a/opal/mca/hwloc/hwloc131/hwloc/src/topology.c +++ b/opal/mca/hwloc/hwloc131/hwloc/src/topology.c @@ -1,7 +1,7 @@ /* * Copyright © 2009 CNRS * Copyright © 2009-2011 INRIA. All rights reserved. - * Copyright © 2009-2010 Université Bordeaux 1 + * Copyright © 2009-2012 Université Bordeaux 1 * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ @@ -1713,7 +1713,10 @@ hwloc_connect_levels(hwloc_topology_t topology) /* New level. */ taken_objs = malloc((n_taken_objs + 1) * sizeof(taken_objs[0])); /* New list of pending objects. */ - new_objs = malloc((n_objs - n_taken_objs + n_new_objs) * sizeof(new_objs[0])); + if (n_objs - n_taken_objs + n_new_objs) + new_objs = malloc((n_objs - n_taken_objs + n_new_objs) * sizeof(new_objs[0])); + else + new_objs = NULL; n_new_objs = hwloc_level_take_objects(top_obj, objs, n_objs, @@ -1765,7 +1768,8 @@ hwloc_connect_levels(hwloc_topology_t topology) } /* It's empty now. */ - free(objs); + if (objs) + free(objs); topology->bridge_nbobjects = hwloc_build_level_from_list(topology->first_bridge, &topology->bridge_level); topology->pcidev_nbobjects = hwloc_build_level_from_list(topology->first_pcidev, &topology->pcidev_level);