Fix a crash in httpGetXpath()

doc, err := gokogiri.ParseHtml(buf) can leave both err and doc nil. Added a
check condition for that.
configurable-file-paths
Robert Gerus 2015-11-22 01:59:57 +01:00
parent 130b600923
commit 294fb3fdf8
1 changed files with 3 additions and 0 deletions

View File

@ -62,6 +62,9 @@ func httpGetXpath(l, x string) (string, error) {
if err != nil {
return "", err
}
if doc.Root() == nil {
return "", errElementNotFound
}
xpath := xpath.Compile(x)
sr, err := doc.Root().Search(xpath)