From ea1cdcd4782b64fdbd8bf5b8ced52d58e204f0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 8 May 2013 13:02:51 +0200 Subject: [PATCH] Assert non-empty state quantities. This avoids generating a null-pointer dereference for &s[0] in case of s.empty(). --- ImpesTPFAAD.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ImpesTPFAAD.hpp b/ImpesTPFAAD.hpp index 7fcb5c679..6e3734c94 100644 --- a/ImpesTPFAAD.hpp +++ b/ImpesTPFAAD.hpp @@ -75,6 +75,8 @@ namespace Opm { { const std::vector& s = state.saturation(); + assert (s.size() == std::vector::size_type(nc_ * np_)); + double* dkrds = 0; // Ignore rel-perm derivatives fluid_.relperm(nc_, & s[0], & cells_[0], kr_.data(), dkrds); @@ -86,6 +88,9 @@ namespace Opm { const std::vector& p = state.pressure(); const std::vector& z = state.surfacevol(); + assert (p.size() == std::vector::size_type(nc_ * 1 )); + assert (z.size() == std::vector::size_type(nc_ * np_)); + fluid_.matrix (nc_, & p[0], & z[0], & cells_[0], A_ .data(), dA_ .data());