Skip to content

Commit

Permalink
Fix for invalid memory address or nil pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
Dharmey747 committed Nov 2, 2023
1 parent fd2b5f7 commit 5167b19
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions soup.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ func (r Root) Attrs() map[string]string {

// Text returns the string inside a non-nested element
func (r Root) Text() string {
if r.Pointer == nil {
if debug {
panic("Pointer text node is nil")
}

return ""
}

k := r.Pointer.FirstChild
checkNode:
if k != nil && k.Type != html.TextNode {
Expand Down

0 comments on commit 5167b19

Please sign in to comment.