grafov / m3u8

Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:
http://tools.ietf.org/html/draft-pantos-http-live-streaming
BSD 3-Clause "New" or "Revised" License
1.23k stars 315 forks source link

MediaPlaylist decode custom tag panic #164

Open panda1986 opened 4 years ago

panda1986 commented 4 years ago

func (p MediaPlaylist) decode(buf bytes.Buffer, strict bool) error { var eof bool var line string var err error

state := new(decodingState)
wv := new(WV)

for !eof {
    if line, err = buf.ReadString('\n'); err == io.EOF {
        eof = true
    } else if err != nil {
        break
    }

    err = decodeLineOfMediaPlaylist(p, wv, state, line, strict)
    if strict && err != nil {
        return err
    }

}
if state.tagWV {
    p.WV = wv
}
if strict && !state.m3u {
    return errors.New("#EXTM3U absent")
}
return nil

}


if p has customDecoder, directly decode, but state not initalized, when call decodeLineOfMediaPlaylist will panic