locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.99k stars 443 forks source link

parseKMLCoordinatesAndAttributes can fail #1018

Open tohidemyname opened 1 year ago

tohidemyname commented 1 year ago

I just read a NTS commit: https://github.com/NetTopologySuite/NetTopologySuite/commit/d0dde923299674e3320e256775b1336e72379e2b

The modified code is as follows: else if (attributeNames.Contains(elementName)) { if (attributes == null) { attributes = new Dictionary<string, string>(); }

                    attributes.Add(elementName, xmlStreamReader.ReadElementContentAsString());
                }
                else
                {
                    xmlStreamReader.Skip();
                }

The JTS code is as follows:

          else if (attributeNames.contains(elementName)) {
                if (attributes == null) {
                    attributes = new HashMap<>();
                }

                attributes.put(elementName, xmlStreamReader.getElementText());
            }

It does not handle the else condition. However, airbreather does not mention how to trigger this bug. He can give more feedback on this issue.