From 80f000a605faee780ceeeb65e8c060e918e81b40 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 1 May 2018 11:58:32 +0200 Subject: [PATCH] Avoid creating pointer to invalid memory in get_dof_indices --- include/deal.II/dofs/dof_accessor.templates.h | 14 +++++++++----- include/deal.II/dofs/dof_levels.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 5aa4c4fc18..0ce19502a8 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -3459,11 +3459,15 @@ DoFCellAccessor::get_dof_indices ExcMessage ("Can't ask for DoF indices on artificial cells.")); AssertDimension (dof_indices.size(), this->get_fe().dofs_per_cell); - const types::global_dof_index *cache - = this->dof_handler->levels[this->present_level] - ->get_cell_cache_start (this->present_index, this->get_fe().dofs_per_cell); - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i, ++cache) - dof_indices[i] = *cache; + const auto dofs_per_cell = this->get_fe().dofs_per_cell; + if (dofs_per_cell > 0) + { + const types::global_dof_index *cache + = this->dof_handler->levels[this->present_level] + ->get_cell_cache_start (this->present_index, dofs_per_cell); + for (unsigned int i=0; i