From b3adc3cf27de33d7657ab40fffc46738e71d96eb Mon Sep 17 00:00:00 2001 From: Reza Rastak Date: Tue, 6 Aug 2019 14:58:58 -0600 Subject: [PATCH] Null pointer check added to CellDagaStorage::get_data() --- include/deal.II/base/quadrature_point_data.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/deal.II/base/quadrature_point_data.h b/include/deal.II/base/quadrature_point_data.h index 154ce61bf0..8656eac401 100644 --- a/include/deal.II/base/quadrature_point_data.h +++ b/include/deal.II/base/quadrature_point_data.h @@ -163,6 +163,13 @@ private: * A map to store a vector of data on a cell. */ std::map>> map; + + /** + * @addtogroup Exceptions + */ + DeclExceptionMsg( + ExcCellDataTypeMismatch, + "Cell data is being retrieved with a type which is different than the type used to initialize it"); }; @@ -617,7 +624,10 @@ CellDataStorage::get_data( // the T==DataType: std::vector> res(it->second.size()); for (unsigned int q = 0; q < res.size(); q++) - res[q] = std::dynamic_pointer_cast(it->second[q]); + { + res[q] = std::dynamic_pointer_cast(it->second[q]); + Assert(res[q], ExcCellDataTypeMismatch()); + } return res; } @@ -640,7 +650,10 @@ CellDataStorage::get_data( // does not modify the content of QP objects std::vector> res(it->second.size()); for (unsigned int q = 0; q < res.size(); q++) - res[q] = std::dynamic_pointer_cast(it->second[q]); + { + res[q] = std::dynamic_pointer_cast(it->second[q]); + Assert(res[q], ExcCellDataTypeMismatch()); + } return res; } -- 2.39.5