From 4526ae64264f6ba8b3cd61a14e081086583d85d5 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 11 May 2020 18:20:48 +0200 Subject: [PATCH] Fix out of memory crash with map generation --- .../src/main/java/net/osmand/data/TransportRoute.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/data/TransportRoute.java b/OsmAnd-java/src/main/java/net/osmand/data/TransportRoute.java index 64839b8649..387c655112 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/TransportRoute.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/TransportRoute.java @@ -124,8 +124,10 @@ public class TransportRoute extends MapObject { if(reverseSecond) { second.reverseNodes(); } - for (int i = 1; i < second.getNodes().size(); i++) { - first.addNode(second.getNodes().get(i)); + if (first != second && (first.getId() < 0 || first.getId() != second.getId())) { + for (int i = 1; i < second.getNodes().size(); i++) { + first.addNode(second.getNodes().get(i)); + } } changed = true; } else {