title: Line 1034: Char 34: runtime error: applying non-zero offset 8 to null pointer (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
body: <pre><code>class Solution {
  public:
      static bool nonDec(vector&lt;int&gt; a, vector&lt;int&gt; b){
          return ((a[0]*a[1])&gt;(b[0]*b[1]));
      };
      
      int maxHeight(vector&lt;vector&lt;int&gt;&gt;&amp; cuboids) {
          int n=cuboids.size();
          int rotLength=3*n;
          vector&lt;vector&lt;int&gt;&gt; rot(rotLength);
          //rot 0-&gt;length//1-&gt;width//2-&gt;height
          int index=0;
          for(int i=0;i&lt;n;i++){
              rot[index][2]=cuboids[i][2];
              rot[index][0]=cuboids[i][0];
              rot[index][1]=cuboids[i][1];
              index++;
              
              rot[index][2]=cuboids[i][0];
              rot[index][1]=max(cuboids[i][1],cuboids[i][2]);
              rot[index][1]=min(cuboids[i][1],cuboids[i][2]);
              index++;
              
              
              rot[index][2]=cuboids[i][1];
              rot[index][1]=max(cuboids[i][0],cuboids[i][2]);
              rot[index][1]=min(cuboids[i][0],cuboids[i][2]);
              index++;
          }
          n=3*n;
          sort(rot.begin(),rot.end(),nonDec);
          vector&lt;int&gt; msh;
          for(int i=0;i&lt;n;i++){ msh[i]=rot[i][2];}
          for(int i=1;i&lt;n;i++){
              for(int j=0;j&lt;i;j++){
                  if(rot[i][1]&lt;=rot[j][1] &amp;&amp; rot[i][0]&lt;=rot[j][0] &amp;&amp; rot[i][2]&lt;=rot[j][2] &amp;&amp; msh[i]&lt;msh[j]+rot[i][2]){
                      msh[i]=msh[j]+rot[i][2];
                  }
              }
          }
          int maxValue=0;
          for(int i=0;i&lt;n;i++){
              if(msh[i]&gt;maxValue){
                  maxValue=msh[i];
              }
          }
          return maxValue;
      }
  };
  </code></pre>
  <p>Link to problem: <a href="https://leetcode.com/problems/maximum-height-by-stacking-cuboids/" rel="nofollow noreferrer">https://leetcode.com/problems/maximum-height-by-stacking-cuboids/</a>
  Error : Line 1034: Char 34: runtime error: applying non-zero offset 8 to null pointer (stl_vector.h)
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34</p>