Skip to content

Commit

Permalink
fix a crash risk
Browse files Browse the repository at this point in the history
  • Loading branch information
macbookpro committed Jan 6, 2019
1 parent 9810288 commit e60e735
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions rtsp/rtsp-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,22 @@ func (client *RTSPClient) requestStream(timeout time.Duration) (err error) {
headers = make(map[string]string)
headers["Accept"] = "application/sdp"
resp, err = client.Request("DESCRIBE", headers)
authorization, _ := client.checkAuth("DESCRIBE", resp)
if len(authorization) > 0 {
headers := make(map[string]string)
headers["Authorization"] = authorization
headers["Accept"] = "application/sdp"
resp, err = client.Request("DESCRIBE", headers)
}
if err != nil {
return err
if resp != nil {
authorization, _ := client.checkAuth("DESCRIBE", resp)
if len(authorization) > 0 {
headers := make(map[string]string)
headers["Authorization"] = authorization
headers["Accept"] = "application/sdp"
resp, err = client.Request("DESCRIBE", headers)
}
if err != nil {
return err
}
} else {
return err
}
}

_sdp, err := sdp.ParseString(resp.Body)
if err != nil {
return err
Expand Down

0 comments on commit e60e735

Please sign in to comment.