Skip to content

Commit

Permalink
Avoid nil pointer dereference with Geckodriver 0.16+
Browse files Browse the repository at this point in the history
Geckodriver 0.15 changed the response to NewSession to move all data
under the "Value" field, as per the emerging WebDriver specification.

This issue is only triggered when Geckodriver is used directly.

Fixes #60.
  • Loading branch information
minusnine committed May 10, 2017
1 parent e9a9439 commit 6afc630
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,17 @@ func (wd *remoteWD) NewSession() (string, error) {
return "", err
}

wd.id = *reply.SessionID
if reply.SessionID != nil {
wd.id = *reply.SessionID
} else if len(reply.Value) > 0 {
value := new(struct {
SessionID string
})
if err := json.Unmarshal(reply.Value, value); err != nil {
return "", fmt.Errorf("error unmarshalling value: %v", err)
}
wd.id = value.SessionID
}

return wd.id, nil
}
Expand Down

0 comments on commit 6afc630

Please sign in to comment.