Skip to content

Commit 097f241

Browse files
authored
Merge pull request open-mpi#13387 from jsquyres/pr/fortran-c2-string-again
fortran: fix off-by-one string copy error
2 parents 3f84c4d + cc03d5b commit 097f241

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ompi/mpi/fortran/base/strings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int ompi_fortran_string_c2f(const char *cstr, char *fstr, int len)
101101
// trailing \0 into the last position in fstr. This is not what
102102
// Fortran wants; overwrite that \0 with the actual last character
103103
// that will fit into fstr.
104-
if (len < strlen(cstr)) {
104+
if (len <= strlen(cstr)) {
105105
fstr[len - 1] = cstr[len - 1];
106106
} else {
107107
// Otherwise, pad the end of the resulting Fortran string with

0 commit comments

Comments
 (0)