Skip to content

Commit

Permalink
Some safety additions in mossco_strings and mossco_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
platipodium committed Aug 22, 2017
1 parent 18bfa40 commit 2c3d927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/utilities/mossco_attribute.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!> @brief Implementation of extensions to the ESMF Attribute utilities
!
! This computer program is part of MOSSCO.
!> @copyright Copyright (C) 2015, 2016 Helmholtz-Zentrum Geesthacht
!> @copyright Copyright (C) 2015, 2016, 2017 Helmholtz-Zentrum Geesthacht
!> @author Carsten Lemmen <carsten.lemmen@hzg.de>
!
! MOSSCO is free software: you can redistribute it and/or modify it under the
Expand Down Expand Up @@ -743,9 +743,15 @@ subroutine MOSSCO_GridCompAttributeGetList1(gridComp, label, stringList, rc)
if (.not.isPresent) return

call ESMF_AttributeGet(gridComp, trim(label), value=attributeString, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc_)) &
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc_)) then
call ESMF_LogWrite(trim(label), ESMF_LOGMSG_ERROR)
if (present(rc)) then
rc=localrc
return
endif
call ESMF_Finalize(rc=localrc, endflag=ESMF_END_ABORT)

endif

n=1
do i=1,len_trim(attributeString)
if (attributeString(i:i)==',') n=n+1
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/mossco_strings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ subroutine MOSSCO_StringMatchPattern(item, pattern, isMatch, rc)
if (p0<1) return

!> Look for simple one trailing asterisk
if (p0 == len_trim(pattern)) then
if (p0 == len_trim(pattern) .and. len_trim(item) >= p0 - 1) then
if (item(1:p0-1) == pattern(1:p0-1)) then
isMatch = .true.
return
Expand Down

0 comments on commit 2c3d927

Please sign in to comment.