Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4480 Segfault in OSRM serializer with bannerInstructions when destination is on roundabout #4481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"));
}
Loading