Fix for ArrayIndexOutOfBoundsException on genre -1
Brought to you by:
heer
A number of MP3 files in my library contain ID3 tags
with a genre value of -1. The getGenreS method in
ID3Tag currently does not handle this gracefully,
producing an ArrayIndexOutOfBoundsException when it
attempts to retrieve the corresponding genre name from
the genres array.
The fix is to return UNKNOWN_GENRE if the genre value
is less than zero:
/** @return String representation of the genre */
public String getGenreS () {
if (genre >= genres.length || genre < 0)
return UNKNOWN_GENRE;
return genres[genre];
}
Patched copy of the latest CVS version of ID3Tag.java
attached.
Patched ID3Tag class