File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
1212 * Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
13- * Copyright (c) 2014-2015 Research Organization for Information Science
14- * and Technology (RIST). All rights reserved.
13+ * Copyright (c) 2014-2024 Research Organization for Information Science
14+ * and Technology (RIST). All rights reserved.
1515 * Copyright (c) 2014 Intel, Inc. All rights reserved.
1616 * $COPYRIGHT$
1717 *
@@ -77,16 +77,18 @@ char *opal_basename(const char *filename)
7777
7878 /* Remove trailing sep's (note that we already know that strlen > 0) */
7979 tmp = strdup (filename );
80- for (i = strlen (tmp ) - 1 ; i > 0 ; -- i ) {
81- if (sep == tmp [i ]) {
82- tmp [i ] = '\0' ;
83- } else {
84- break ;
80+ if (1 < strlen (tmp )) {
81+ for (i = strlen (tmp ) - 1 ; i > 0 ; -- i ) {
82+ if (sep == tmp [i ]) {
83+ tmp [i ] = '\0' ;
84+ } else {
85+ break ;
86+ }
87+ }
88+ if (0 == i ) {
89+ tmp [0 ] = sep ;
90+ return tmp ;
8591 }
86- }
87- if (0 == i ) {
88- tmp [0 ] = sep ;
89- return tmp ;
9092 }
9193
9294 /* Look for the final sep */
You can’t perform that action at this time.
0 commit comments