#4950 closed defect (fixed)
Bad loop over attribute list
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | latest |
Keywords: | gcj | Cc: |
Description
file :src/org/openstreetmap/josm/io/OsmApi.java
line 124: for (int i=0; i< qName.length(); i++) {
it loops over the chars in the string to get the attributes, this causes an out of bounds error.
the code should be :
for (int i=0; i< atts.getLength(); i++) {
see my code changes here :
http://github.com/h4ck3rm1k3/josm/commit/63901da2138bc050e39fbc7c0277163396f6e73c
error message :
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
at java.util.ArrayList.raiseBoundsError(libgcj.so.10)
at java.util.ArrayList.checkBoundExclusive(libgcj.so.10)
at java.util.ArrayList.get(libgcj.so.10)
at gnu.xml.stream.XMLParser.getAttributeName(libgcj.so.10)
at gnu.xml.stream.SAXParser.getQName(libgcj.so.10)
at org.openstreetmap.josm.io.OsmApi$CapabilitiesParser.startElement(josm)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
This is why we should be testing with the gcj because it catches such sloppy code.
(In [3212]) fixed #4950 - Bad loop over attribute list (patch by jamesmikedupont)