CPP - core dumbed while using vector<string> : So on ubuntu i always get core dumped when trying to execute this function:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    vector<string> inArray(vector<string> &array1, vector<string> &array2){
        vector<string> result;

            for(int i=0;i<array1.size();i++){

                for(int j=0;j<array2.size();j++){
                      if(array1[i] == array2[j])result.push_back(array1[i]);
                }

            }

          return result;
    }

<!-- end snippet -->

Can someone tell me what is wrong?