Skip to content

Commit 15e4a3c

Browse files
authored
[flang][runtime] Fix namelist substring checking (llvm#78649)
An || operator in namelist substring bounds checking really needs to be an && operator so that the substring is viewed as correct only when both its bounds are valid. Fixes llvm-test-suite/Fortran/gfortran/regression/namelist_40.f90.
1 parent b788d62 commit 15e4a3c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/runtime/namelist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static bool HandleSubstring(
313313
desc.raw().elem_len = 0;
314314
return true;
315315
}
316-
if (*lower >= 1 || *upper <= chars) {
316+
if (*lower >= 1 && *upper <= chars) {
317317
// Offset the base address & adjust the element byte length
318318
desc.raw().elem_len = (*upper - *lower + 1) * kind;
319319
desc.set_base_addr(reinterpret_cast<void *>(

0 commit comments

Comments
 (0)