Skip to content

Commit

Permalink
Fixes #4480 Segfault in OSRM serializer with bannerInstructions when …
Browse files Browse the repository at this point in the history
…destination is on roundabout (#4481)

* OSRM serializer with bannerInstructions should not segfault when ending on a roundabout

* Adds Changelog entry
  • Loading branch information
eikes committed Dec 29, 2023
1 parent d1c11dd commit 9f46abb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
* UPDATED: updated country access overrides [#4460](https://github.com/valhalla/valhalla/pull/4460)
* CHANGED: date_time refactor as a preparation to return DST/timezone related offset in the response [#4365](https://github.com/valhalla/valhalla/pull/4365)
* ADDED: find connection on backward search for bidir matrix algo [#4329](https://github.com/valhalla/valhalla/pull/4329)
* FIXED: Fix segfault in OSRM serializer with bannerInstructions when destination is on roundabout [#4480](https://github.com/valhalla/valhalla/pull/4481)

## Release Date: 2023-05-11 Valhalla 3.4.0
* **Removed**
Expand Down
4 changes: 3 additions & 1 deletion src/tyr/route_serializer_osrm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,9 @@ uint32_t calc_roundabout_turn_degrees(const valhalla::DirectionsLeg::Maneuver* p
}

uint32_t end_index = maneuver.end_path_index();
bearing_after = etp->GetCurrEdge(end_index)->begin_heading();
if (etp->GetCurrEdge(end_index) != nullptr) {
bearing_after = etp->GetCurrEdge(end_index)->begin_heading();
}
}

if (prev_maneuver != nullptr && maneuver.type() == DirectionsLeg_Maneuver_Type_kRoundaboutExit) {
Expand Down
11 changes: 11 additions & 0 deletions test/gurka/test_osrm_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,14 @@ TEST_F(Rotary, BannerInstructionsRotaryEastWest) {
EXPECT_STREQ(primary_1["driving_side"].GetString(), "right");
EXPECT_STREQ(primary_1["text"].GetString(), "Eastern Road");
}

TEST_F(Rotary, EndOnRotary) {
// This is just a test that ending on the rotary doesn't cause a segfault :D
auto json = json_request("Q", "F");
auto steps = json["routes"][0]["legs"][0]["steps"].GetArray();

auto primary_0 = steps[0]["bannerInstructions"][0]["primary"].GetObject();

EXPECT_STREQ(primary_0["type"].GetString(), "rotary");
ASSERT_TRUE(primary_0.HasMember("degrees"));
}

0 comments on commit 9f46abb

Please sign in to comment.