Skip to content

Commit 8e45df1

Browse files
committed
opal/datatype: correctly handle zero size datatype or zero count
Signed-off-by: Gilles Gouaillardet <[email protected]> (cherry picked from commit bf0fc4a)
1 parent a79583e commit 8e45df1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

opal/datatype/opal_datatype.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* reserved.
1515
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1616
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
17+
* Copyright (c) 2017 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -344,6 +346,9 @@ opal_datatype_span( const opal_datatype_t* pData, int64_t count,
344346
{
345347
OPAL_PTRDIFF_TYPE extent = (pData->ub - pData->lb);
346348
OPAL_PTRDIFF_TYPE true_extent = (pData->true_ub - pData->true_lb);
349+
if (OPAL_UNLIKELY(0 == pData->size) || (0 == count)) {
350+
return 0;
351+
}
347352
*gap = pData->true_lb;
348353
return true_extent + (count - 1) * extent;
349354
}

0 commit comments

Comments
 (0)