I try to figure out where the problem is. Unfortunately I do not see a potential problem in the code. I do not use pointers and I do not use any "new" in the code.
Maybe it is a problem with std::set I use as container to store the data. I will check if I can replace it with either std::vector or a root class.