From: Daniel Arndt Date: Tue, 1 May 2018 09:58:32 +0000 (+0200) Subject: Avoid creating pointer to invalid memory in get_dof_indices X-Git-Tag: v9.0.0-rc1~50^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80f000a605faee780ceeeb65e8c060e918e81b40;p=dealii.git Avoid creating pointer to invalid memory in get_dof_indices --- 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