integer overflow in dict_hashkey
Brought to you by:
arjenmarkus
It seems that the do loop in function dict_hashkey in datastructures/dictionary.f90 can overflow fairly easily since dict_hashkey is an INTEGER(4). This can cause cause a segmentation fault in dict_get_elem if dict_hashkey returns a negative number. My quick fix was to just put an absolute value on dict_hashkey at the end of the do loop, i.e.
integer function dict_hashkey( key )
character(len=*), intent(in) :: key
integer :: hash
integer :: i
dict_hashkey = 0
do i = 1,len(key)
dict_hashkey = multiplier * dict_hashkey + ichar(key(i:i))
enddo
dict_hashkey = 1 + mod( abs(dict_hashkey-1), hash_size )
end function dict_hashkey