From: David Wells Date: Sun, 14 Aug 2016 23:03:17 +0000 (-0400) Subject: Don't possibly dereference a null pointer. X-Git-Tag: v8.5.0-rc1~771^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b0bae9de0f2720496b17c20fb3f65bd49bab717;p=dealii.git Don't possibly dereference a null pointer. Since this code checks that the dimension really is not 1 we can get rid of this case, which would result in an ill-formed reference. --- diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index f1d6f9b789..8918c6e503 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -3552,17 +3552,17 @@ namespace internal { typedef std::list LineList; - // get a pointer to the flags - // common to all dimensions, in - // order to avoid the recurring - // distinctions between - // eps_flags_1, eps_flags_2, ... - const GridOutFlags::EpsFlagsBase - &eps_flags_base = (dim==2 ? - static_cast(eps_flags_2) : - (dim==3 ? - static_cast(eps_flags_3) : - *static_cast(0))); + // We should never get here in 1D since this function is overloaded for + // all dim == 1 cases. + Assert(dim == 2 || dim == 3, ExcInternalError()); + + // Copy, with an object slice, something containing the flags common to + // all dimensions in order to avoid the recurring distinctions between + // the different eps_flags present. + const GridOutFlags::EpsFlagsBase eps_flags_base = + dim == 2 ? + static_cast(eps_flags_2) : + static_cast(eps_flags_3); AssertThrow (out, ExcIO()); const unsigned int n_points = eps_flags_base.n_boundary_face_points;