Most likely, the line
for (int i = 0; i <= locations_original.size(); i++)
should be replaced with
for (int i = 0; i < locations_original.size(); i++)
Do I even have to explain why? This is elementary mathematics; and most developers catch this bug from the first glance, at the level of reflexes, because right code is a very common pattern: a range of N elements is indexed from 0 to N−1.
—SA