title: Line 924: Char 9: runtime error: reference binding to null pointer of type 'int' (stl_vector.h)
body: <p>I am getting runtime error while running the following code on leetcode.
  When I am removing the user-defined comparator function it is working fine. But with user define comparator function it is giving runtime error as follows :</p>
  <blockquote>
  <p>Line 924: Char 9: runtime error: reference binding to null pointer of
  type 'int' (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer:
  undefined-behavior
  /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_vector.h:933:9</p>
  </blockquote>
  <pre><code>class Solution {
  private:
      static bool comp (vector&lt;int&gt; p1, vector&lt;int&gt; p2) {
          if(p1[0] &lt; p2[0] || p1[1] &lt; p2[1])
              return true;
          else
              return false;
      }
      
  public:
      int maxEnvelopes(vector&lt;vector&lt;int&gt;&gt;&amp; envelopes) {
          if (envelopes.empty())
              return 0;
          sort(envelopes.begin(), envelopes.end(), comp);
          vector&lt;int&gt; dp(envelopes.size(), 1);
          int res = 0;
          
          for (int i = 0; i &lt; envelopes.size(); i++) {
              for (int j = i-1; j &gt;=0; j--) {
                  if (envelopes[j][0] &lt; envelopes[i][0] &amp;&amp; envelopes[j][1] &lt; envelopes[i][1] &amp;&amp; dp[j] + 1 &gt; dp[i])
                      dp[i] = 1 + dp[j];
              }
              res = max(res, dp[i]);
          }
          
          return res;
      }
  };
  </code></pre>