Skip to content

Commit 426796a

Browse files
committed
Fix inner/outer ring accessor boost::geometry adaptor types/functions
These types/functions are used to let boost functions access our polygon/ring types. They are supposed to return (const) references. I found the bug while doing more complicated geometry processing, working on some future code for osm2pgsql. It seems the buggy code does not produce any problems in current code, but I can not guarantee it. Theoretically it could lead to crashes. It might make some code slower, though, because of unnecessary copying.
1 parent da5a1d5 commit 426796a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/geom-boost-adaptor.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,30 @@ struct ring_mutable_type<::geom::polygon_t>
5454
template <>
5555
struct interior_const_type<::geom::polygon_t>
5656
{
57-
using type = std::vector<::geom::ring_t> const;
57+
using type = std::vector<::geom::ring_t> const &;
5858
};
5959
template <>
6060
struct interior_mutable_type<::geom::polygon_t>
6161
{
62-
using type = std::vector<::geom::ring_t>;
62+
using type = std::vector<::geom::ring_t> &;
6363
};
6464

6565
template <>
6666
struct exterior_ring<::geom::polygon_t>
6767
{
6868
// NOLINTNEXTLINE(google-runtime-references)
6969
static auto &get(::geom::polygon_t &p) { return p.outer(); }
70-
static auto &get(::geom::polygon_t const &p) { return p.outer(); }
70+
static auto const &get(::geom::polygon_t const &p) { return p.outer(); }
7171
};
7272

7373
template <>
7474
struct interior_rings<::geom::polygon_t>
7575
{
7676
// NOLINTNEXTLINE(google-runtime-references)
77-
static auto get(::geom::polygon_t &p) { return p.inners(); }
78-
static auto get(::geom::polygon_t const &p) { return p.inners(); }
77+
static auto &get(::geom::polygon_t &p) { return p.inners(); }
78+
static auto const &get(::geom::polygon_t const &p) { return p.inners(); }
7979
};
80+
8081
} // namespace boost::geometry::traits
8182

8283
#endif // OSM2PGSQL_GEOM_BOOST_ADAPTOR_HPP

0 commit comments

Comments
 (0)