Skip to content

Commit 23f2784

Browse files
committed
Fix case where var->mbv_enumerator can be released when static.
Signed-off-by: Austen Lauria <[email protected]>
1 parent e534c57 commit 23f2784

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

opal/mca/base/mca_base_var.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ static int mca_base_var_count = 0;
8484

8585
static opal_hash_table_t mca_base_var_index_hash;
8686

87+
#define OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(mbv_enumerator) { \
88+
if(mbv_enumerator && !mbv_enumerator->enum_is_static) { \
89+
OBJ_RELEASE(mbv_enumerator); \
90+
} \
91+
}
92+
8793
const char *ompi_var_type_names[] = {
8894
"int",
8995
"unsigned_int",
@@ -870,8 +876,8 @@ int mca_base_var_deregister(int vari)
870876
var->mbv_storage->stringval) {
871877
free (var->mbv_storage->stringval);
872878
var->mbv_storage->stringval = NULL;
873-
} else if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) {
874-
OBJ_RELEASE(var->mbv_enumerator);
879+
} else {
880+
OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var -> mbv_enumerator);
875881
}
876882

877883
var->mbv_enumerator = NULL;
@@ -1517,10 +1523,7 @@ static int register_variable (const char *project_name, const char *framework_na
15171523
if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) {
15181524
enumerator = &mca_base_var_enum_bool;
15191525
} else if (NULL != enumerator) {
1520-
if (var->mbv_enumerator) {
1521-
OBJ_RELEASE (var->mbv_enumerator);
1522-
}
1523-
1526+
OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var->mbv_enumerator);
15241527
if (!enumerator->enum_is_static) {
15251528
OBJ_RETAIN(enumerator);
15261529
}
@@ -1906,9 +1909,7 @@ static void var_destructor(mca_base_var_t *var)
19061909
}
19071910

19081911
/* don't release the boolean enumerator */
1909-
if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) {
1910-
OBJ_RELEASE(var->mbv_enumerator);
1911-
}
1912+
OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var->mbv_enumerator);
19121913

19131914
if (NULL != var->mbv_long_name) {
19141915
free(var->mbv_long_name);

0 commit comments

Comments
 (0)