From c507e2d3b6c72ccf56e6dbd80ae6a5f2a5e3507e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 27 Oct 2022 15:56:59 -0400 Subject: [PATCH] avoid potenttial out-of-bounds memory access --- src/IO.f90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 6de0b7762..1643cac71 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -252,9 +252,13 @@ pure function IO_lc(string) integer :: i,n - do i=1,len(string) + do i = 1,len(string) n = index(UPPER,string(i:i)) - IO_lc(i:i) = merge(string(i:i),LOWER(n:n),n==0) + if (n==0) then + IO_lc(i:i) = string(i:i) + else + IO_lc(i:i) = LOWER(n:n) + end if end do end function IO_lc