Changeset 18202 in josm for trunk/src/org


Ignore:
Timestamp:
2021-09-08T13:55:01+02:00 (3 years ago)
Author:
Don-vip
Message:

see #21300 - fix potential NPE detected by coverity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r18195 r18202  
    21502150                UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key);
    21512151                if (unaryFactory != null)
    2152                     return unaryFactory.get(key, parseFactor(), tokenizer).validate();
     2152                    return getValidate(unaryFactory, key, tokenizer);
    21532153
    21542154                // key:value form where value is a string (may be OSM key search)
     
    21642164                UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key);
    21652165                if (unaryFactory != null)
    2166                     return unaryFactory.get(key, parseFactor(), null).validate();
     2166                    return getValidate(unaryFactory, key, null);
    21672167
    21682168                // match string in any key or value
     
    21752175    private Match parseFactor(String errorMessage) throws SearchParseError {
    21762176        return Optional.ofNullable(parseFactor()).orElseThrow(() -> new SearchParseError(errorMessage));
     2177    }
     2178
     2179    private Match getValidate(UnaryMatchFactory unaryFactory, String key, PushbackTokenizer tokenizer)
     2180            throws SearchParseError {
     2181        UnaryMatch match = unaryFactory.get(key, parseFactor(), tokenizer);
     2182        return match != null ? match.validate() : null;
    21772183    }
    21782184
Note: See TracChangeset for help on using the changeset viewer.