Unverified Commit 81fdbc2c authored by luke's avatar luke Committed by GitHub
Browse files

Fix segfualt caused by empty XML parameter arrays (#3855) (#325)



* Add handling for arrays of strings of zero length.

* Move array allocations to the beginning to ensure the are allocated to the correct length for all cases.
Co-authored-by: default avatarLuke Cornejo <3lc@ornl.gov>
parent 3feffda8
......@@ -16345,6 +16345,7 @@ SUBROUTINE char_to_int_array(iArr,c)
INTEGER(SIK) :: i,j,k
 
numElts=countArrayElts(c)
ALLOCATE(iArr(numElts))
!Empty array case
IF(numElts == 0) THEN
RETURN
......@@ -16352,7 +16353,6 @@ SUBROUTINE char_to_int_array(iArr,c)
 
j=0
k=1 ! iArr index
ALLOCATE(iArr(numElts))
DO i=2,LEN(c)
IF(c(i:i) /= ',' .AND. c(i:i) /= '}') THEN
j=j+1
......@@ -16381,6 +16381,7 @@ SUBROUTINE char_to_double_array(dArr,c)
INTEGER(SIK) :: i,j,k
 
numElts=countArrayElts(c)
ALLOCATE(dArr(numElts))
!Empty array case
IF(numElts == 0) THEN
RETURN
......@@ -16388,7 +16389,6 @@ SUBROUTINE char_to_double_array(dArr,c)
 
j=0
k=1 ! dArr index
ALLOCATE(dArr(numElts))
DO i=2,LEN(c)
IF(c(i:i) /= ',' .AND. c(i:i) /= '}') THEN
j=j+1
......@@ -16417,6 +16417,7 @@ SUBROUTINE char_to_string_array(sArr,c)
INTEGER(SIK) :: i,j,k
 
numElts=countArrayElts(c)
ALLOCATE(sArr(numElts))
!Empty array case
IF(numElts == 0) THEN
RETURN
......@@ -16424,7 +16425,6 @@ SUBROUTINE char_to_string_array(sArr,c)
 
j=0
k=1 ! sArr index
ALLOCATE(sArr(numElts))
DO i=2,LEN(c)
IF(c(i:i) /= ',' .AND. c(i:i) /= '}') THEN
j=j+1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment