@@ -133,16 +133,20 @@ int prte_rmaps_base_get_target_nodes(pmix_list_t *allocated_nodes,
133133 * However, if it is a managed allocation AND the hostfile or the hostlist was
134134 * provided, those take precedence, so process them and filter as we normally do.
135135 */
136- if (prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST , (void * * ) & hosts , PMIX_STRING ) ||
137- prte_get_attribute (& app -> attributes , PRTE_APP_HOSTFILE , (void * * ) & hosts , PMIX_STRING )) {
136+ hosts = NULL ;
137+ if ((prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST , (void * * ) & hosts , PMIX_STRING ) ||
138+ prte_get_attribute (& app -> attributes , PRTE_APP_HOSTFILE , (void * * ) & hosts , PMIX_STRING )) &&
139+ NULL != hosts ) {
138140 needhosts = true;
141+ free (hosts );
139142 }
140143 if (!prte_managed_allocation ||
141144 (prte_managed_allocation && needhosts )) {
142145 PMIX_CONSTRUCT (& nodes , pmix_list_t );
143146 /* if the app provided a dash-host, then use those nodes */
144147 hosts = NULL ;
145- if (prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST , (void * * ) & hosts , PMIX_STRING )) {
148+ if (prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST , (void * * ) & hosts , PMIX_STRING ) &&
149+ NULL != hosts ) {
146150 PMIX_OUTPUT_VERBOSE ((5 , prte_rmaps_base_framework .framework_output ,
147151 "%s using dash_host %s" , PRTE_NAME_PRINT (PRTE_PROC_MY_NAME ),
148152 hosts ));
@@ -152,7 +156,8 @@ int prte_rmaps_base_get_target_nodes(pmix_list_t *allocated_nodes,
152156 return rc ;
153157 }
154158 free (hosts );
155- } else if (prte_get_attribute (& app -> attributes , PRTE_APP_HOSTFILE , (void * * ) & hosts , PMIX_STRING )) {
159+ } else if (prte_get_attribute (& app -> attributes , PRTE_APP_HOSTFILE , (void * * ) & hosts , PMIX_STRING ) &&
160+ NULL != hosts ) {
156161 /* otherwise, if the app provided a hostfile, then use that */
157162 PMIX_OUTPUT_VERBOSE ((5 , prte_rmaps_base_framework .framework_output ,
158163 "%s using hostfile %s" , PRTE_NAME_PRINT (PRTE_PROC_MY_NAME ),
@@ -450,9 +455,12 @@ int prte_rmaps_base_get_target_nodes(pmix_list_t *allocated_nodes,
450455 if (node -> slots > node -> slots_inuse ) {
451456 int32_t s ;
452457 /* check for any -host allocations */
453- if (prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST , (void * * ) & hosts ,
454- PMIX_STRING )) {
458+ hosts = NULL ;
459+ if (prte_get_attribute (& app -> attributes , PRTE_APP_DASH_HOST ,
460+ (void * * ) & hosts , PMIX_STRING ) &&
461+ NULL != hosts ) {
455462 s = prte_util_dash_host_compute_slots (node , hosts );
463+ free (hosts );
456464 } else {
457465 s = node -> slots - node -> slots_inuse ;
458466 }
0 commit comments