File tree 1 file changed +13
-11
lines changed 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 10
10
* Copyright (c) 2004-2005 The Regents of the University of California.
11
11
* All rights reserved.
12
12
* 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.
15
15
* Copyright (c) 2014 Intel, Inc. All rights reserved.
16
16
* $COPYRIGHT$
17
17
*
@@ -77,16 +77,18 @@ char *opal_basename(const char *filename)
77
77
78
78
/* Remove trailing sep's (note that we already know that strlen > 0) */
79
79
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 ;
85
91
}
86
- }
87
- if (0 == i ) {
88
- tmp [0 ] = sep ;
89
- return tmp ;
90
92
}
91
93
92
94
/* Look for the final sep */
You can’t perform that action at this time.
0 commit comments