title: Stack around variable is corrupted
body: <p>I know this topic has a lot of questions, but they all seem specific to the code.</p>
  
  <p>I have this function - </p>
  
  <pre><code>Point2 ITCS4120::operator* (const Matrix3x3&amp; m, const Point2&amp; p) {
     Point2 result;
     for(int i=0;i&lt;3;i++) {
         result[i] = (m[i][0]*p[0]) + (m[i][1]*p[1]) + (m[i][2]);
         }
     return result; //error here
     }
  </code></pre>
  
  <p>It gives me an error on the return statement saying "Run-Time Check Failure #2 - Stack around the variable 'result' was corrupted."</p>
  
  <p>I cannot see anything wrong with that function. The Matrix3x3's array is just - </p>
  
  <pre><code>float array[3][3];
  </code></pre>
  
  <p>and the Point2's array is </p>
  
  <pre><code>float array [2];
  </code></pre>
  
  <p>Both the Matrix3x3 and Point2 classes have this code -</p>
  
  <pre><code>/** Write access for element in row [i] */
  inline Scalar* operator[](int i) {return array[i];}
  /** Read access for element in row [i] */
  inline const Scalar* operator[](int i)const {return array[i];}
  </code></pre>
  
  <p>This code was given to me and I had some previous homework to do arithmetic with points, matricis, and vectors. My code passed all the tests so I assumed my Point2 ITCS4120::operator* (const Matrix3x3&amp; m, const Point2&amp; p) code was correct. But maybe I need to use the [] operators differently?</p>