Skip to content

Commit ebeca1d

Browse files
committed
mpool/hugepage CID 1516781: fix strtok usage
I think that in practice, strtok will never return NULL the first time it is invoked on the options string, but we might as well be defensive and protect that case. Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 02add5f commit ebeca1d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

opal/mca/mpool/hugepage/mpool_hugepage_component.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2006 Voltaire. All rights reserved.
14-
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2007-2022 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
1616
* reserved.
1717
* Copyright (c) 2016 Intel, Inc. All rights reserved.
@@ -238,9 +238,8 @@ static void mca_mpool_hugepage_find_hugepages(void)
238238
}
239239

240240
tok = strtok_r(opts, ",", &ctx);
241-
242241
do {
243-
if (0 == strncmp(tok, "pagesize", 8)) {
242+
if (NULL != tok && 0 == strncmp(tok, "pagesize", 8)) {
244243
break;
245244
}
246245
tok = strtok_r(NULL, ",", &ctx);

0 commit comments

Comments
 (0)