From b69b30a03034483912a16abe1887ecf34bf0232c Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 25 Sep 2020 11:47:46 +0300 Subject: [PATCH] Fix countWords npe --- .../java/net/osmand/search/core/SearchPhrase.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java index f1b5b45b05..2a3fc59521 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java @@ -229,12 +229,14 @@ public class SearchPhrase { } public int countWords(String w) { - String[] ws = w.split(ALLDELIMITERS); int cnt = 0; - for (int i = 0; i < ws.length; i++) { - String wd = ws[i].trim(); - if (wd.length() > 0) { - cnt++; + if (!Algorithms.isEmpty(w)) { + String[] ws = w.split(ALLDELIMITERS); + for (int i = 0; i < ws.length; i++) { + String wd = ws[i].trim(); + if (wd.length() > 0) { + cnt++; + } } } return cnt;