diff --git a/src/fpm/dependency.f90 b/src/fpm/dependency.f90 index 71bc74514f..ee048e2df9 100644 --- a/src/fpm/dependency.f90 +++ b/src/fpm/dependency.f90 @@ -406,6 +406,9 @@ recursive subroutine add_project_dependencies(self, package, root, main, error) end if end if + !> Ensure allocation fits + call resize(self%dep,self%ndep) + end subroutine add_project_dependencies !> Add a list of dependencies to the dependency tree @@ -430,6 +433,9 @@ subroutine add_dependencies(self, dependency, error) end do if (allocated(error)) return + !> Ensure allocation fits ndep + call resize(self%dep,self%ndep) + end subroutine add_dependencies !> Add a single dependency node to the dependency tree @@ -464,6 +470,10 @@ subroutine add_dependency_node(self, dependency, error) end if end if else + + !> Safety: reallocate if necessary + if (size(self%dep)==self%ndep) call resize(self%dep,self%ndep+1) + ! New dependency: add from scratch self%ndep = self%ndep + 1 self%dep(self%ndep) = dependency