Skip to content

Commit 9e306ce

Browse files
authored
Merge pull request #6336 from jsquyres/pr/v4.0.x/fix-datatype-destructor-leak
v4.0.x: opal/datatype: plug a memory leak in opal_datatype_t destructor
2 parents 8552d0e + 0ae4847 commit 9e306ce

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

opal/datatype/opal_datatype_clone.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* All rights reserved.
1313
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1414
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
15+
* Copyright (c) 2019 Research Organization for Information Science
16+
* and Technology (RIST). All rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -41,6 +43,7 @@ int32_t opal_datatype_clone( const opal_datatype_t * src_type, opal_datatype_t *
4143
sizeof(opal_datatype_t)-sizeof(opal_object_t) );
4244

4345
dest_type->flags &= (~OPAL_DATATYPE_FLAG_PREDEFINED);
46+
dest_type->ptypes = NULL;
4447
dest_type->desc.desc = temp;
4548

4649
/**

opal/datatype/opal_datatype_create.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Copyright (c) 2004-2006 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
14+
* Copyright (c) 2019 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -77,7 +79,7 @@ static void opal_datatype_destruct( opal_datatype_t* datatype )
7779
}
7880
}
7981
/* dont free the ptypes of predefined types (it was not dynamically allocated) */
80-
if( (NULL != datatype->ptypes) && (datatype->id >= OPAL_DATATYPE_MAX_PREDEFINED) ) {
82+
if( (NULL != datatype->ptypes) && (!opal_datatype_is_predefined(datatype)) ) {
8183
free(datatype->ptypes);
8284
datatype->ptypes = NULL;
8385
}

0 commit comments

Comments
 (0)