void change_degree(vector<int> &nodes, map<int, vector<int> > &edges, int vertex){
map<int, vector<int> >::iterator ite;
ite = edges.find(vertex);
vector<int> temp = (*ite).second;
vector<int>::iterator it;
for(it = temp.begin(); it != temp.end(); it++){
cout << *it;
if(nodes[*it + 1] > 1)
nodes[*it + 1]++;
}
}
This function is producing error
*** glibc detected *** ./a.out: munmap_chunk(): invalid pointer: 0x09c930e0 ***
Can someone tell me why is it coming and what it means?
Thanks in advance.
Well, one issue I see is that you’re not checking to see if
vertexwas actually found inedges. You are probably dereferencing memory you don’t own.Next time, try running your app through GDB, and check your stack trace.
Edit: another possibility is that you’re indexing into
nodesincorrectly. Check thatnodes[*it + 1]is valid.