diff --git a/fhash.f90 b/fhash.f90 index c05af60..7d55e4b 100644 --- a/fhash.f90 +++ b/fhash.f90 @@ -392,7 +392,12 @@ subroutine next(this, key, value, status) VALUE_TYPE, intent(out) :: value integer, optional, intent(out) :: status - do while (.not. associated(this%node_ptr) .or. .not. allocated(this%node_ptr%kv)) + do + + IF(ASSOCIATED(this%node_ptr)) THEN + IF(ALLOCATED(this%node_ptr%kv) ) EXIT + END IF + if (this%bucket_id < this%fhash_ptr%n_buckets) then this%bucket_id = this%bucket_id + 1 this%node_ptr => this%fhash_ptr%buckets(this%bucket_id)