Ignore:
Timestamp:
2017-01-16T23:21:57+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #14257 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r11397 r11472  
    279279                        command.possiblyInterrupt();
    280280                        for (;;) {
    281                             int nBytesRead;
    282                             nBytesRead = audioInputStream.read(abData, 0, abData.length);
    283                             position += nBytesRead / bytesPerSecond;
     281                            int nBytesRead = 0;
     282                            if (audioInputStream != null) {
     283                                nBytesRead = audioInputStream.read(abData, 0, abData.length);
     284                                position += nBytesRead / bytesPerSecond;
     285                            }
    284286                            command.possiblyInterrupt();
    285                             if (nBytesRead < 0) {
     287                            if (nBytesRead < 0 || audioInputStream == null || audioOutputLine == null) {
    286288                                break;
    287289                            }
     
    290292                        }
    291293                        // end of audio, clean up
    292                         audioOutputLine.drain();
    293                         audioOutputLine.close();
     294                        if (audioOutputLine != null) {
     295                            audioOutputLine.drain();
     296                            audioOutputLine.close();
     297                        }
    294298                        audioOutputLine = null;
    295299                        Utils.close(audioInputStream);
Note: See TracChangeset for help on using the changeset viewer.