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

fix(Query): Fix wrong path response for k-shortest paths #6437

Merged
merged 2 commits into from
Sep 14, 2020
Merged
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
7 changes: 6 additions & 1 deletion query/shortest.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ func runKShortestPaths(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) {
continue
}

// Add path to list.
// Add path to list after making a copy of the path in itemRoute. A copy of
// *item.path.route is required because it has to be put back in the sync pool and a
// future reuse can alter the item already present in kroute because it is a pointer.
itemRoute := make([]pathInfo, len(*item.path.route))
copy(itemRoute, *item.path.route)
newRoute := item.path
newRoute.route = &itemRoute
newRoute.totalWeight = item.cost
kroutes = append(kroutes, newRoute)
if len(kroutes) == numPaths {
Expand Down