Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#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.

Attachments (0)

Change History (2)

comment:1 by bastiK, 15 years ago

Resolution: fixed
Status: newclosed

(In [3212]) fixed #4950 - Bad loop over attribute list (patch by jamesmikedupont)

comment:2 by stoecker, 15 years ago

Ticket #4804 has been marked as a duplicate of this ticket.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.