]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Be more careful accessing the data array of a Table object if said Table
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 Jun 2011 23:47:29 +0000 (23:47 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 Jun 2011 23:47:29 +0000 (23:47 +0000)
object is empty. Also add an assertion in one other place.

git-svn-id: https://svn.dealii.org/trunk@23893 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/table.h

index 6bc0ca7fa5eeca526d44f313c85ce4559ea4ab99..1d835d9cced1bb00ba034dba0f345089e434385a 100644 (file)
@@ -2168,6 +2168,8 @@ inline
 typename std::vector<T>::reference
 TableBase<N,T>::el (const TableIndices<N> &indices)
 {
+  Assert (position(indices) < values.size(),
+         ExcIndexRange (position(indices), 0, values.size()));
   return values[position(indices)];
 }
 
@@ -2178,7 +2180,10 @@ inline
 typename std::vector<T>::const_pointer
 TableBase<N,T>::data () const
 {
-  return &values[0];
+  if (values.size() == 0)
+    return 0;
+  else
+    return &values[0];
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.