]> git.openstreetmap.org Git - nominatim.git/commit
Avoid deleting from array that is being looped over (#4228)
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 27 Oct 2026 21:26:01 +0000 (22:26 +0100)
committerGitHub <noreply@github.com>
Tue, 27 Oct 2026 21:26:01 +0000 (22:26 +0100)
commit24cdcb6f04f41cd6647fd3c043cfa7d2bcea4d89
treeb5b228aef73b096964a5342d5e8957e97c6f0600
parentdd2846bbddac14664f6b44e688af465f12b64c6a
parent1fcd8120a958d3b2162950e6a015607c6755f9c1
Avoid deleting from array that is being looped over (#4228)

This fixes a case of deleting an element from an array while looping
over the array in the postcode sanitizer, as found by Copilot (see
#4227).

Python will jump over the the next element after having deleted one, so
that a postcode following an invalid one might not be handled. This case
is very unlikely to appear in the real world because addresses can only
be input with a single postcode. You'd have to use a special sanitizer
to duplicate the entry. And also change the default of actually keeping
the postcode.

To keep the frequent case lean, simply recreate the address item list
without the filtered postcodes in the rare case that a postcode needs to
be deleted.