From: frohne Date: Tue, 12 Feb 2013 21:08:22 +0000 (+0000) Subject: fix memory overwrite in step-42 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6093f3ba4740111de57854ba402d2e9bced941cb;p=dealii-svn.git fix memory overwrite in step-42 git-svn-id: https://svn.dealii.org/trunk@28343 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index d29261436c..02da110ff7 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -177,7 +177,7 @@ namespace Step42 double hv(int i, int j); - double& set_height(int i, int j); + void set_height(int i, int j,double val); double mikro_height(double x,double y, double z); @@ -196,13 +196,22 @@ namespace Step42 template double Input::hv(int i, int j) { + assert(i>=0 && i=0 && j - double& Input::set_height(int i, int j) + void Input::set_height(int i, int j, double val) { - return HV[nx*j+i]; // i indiziert x-werte, j indiziert y-werte + if (i>=nx || j>=ny) + { + std::cout << "invalid:" << i << " " << j << " " << nx*j+i << std::endl; + return; + } + assert(i>=0 && i=0 && j @@ -330,7 +339,7 @@ namespace Step42 if (hlp < min_hlp) min_hlp=hlp; - set_height (k, ny - 1 - j) = hlp; + set_height (k, ny - 1 - j, hlp); int pos = strcspn (zeile, ","); if (!strpbrk (zeile, ",")) {