Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: CharData returned is slice of internal buffer, so it gets overwritten #673

Closed
gopherbot opened this Issue Mar 17, 2010 · 2 comments

Comments

Projects
None yet
1 participant
@gopherbot
Copy link

gopherbot commented Mar 17, 2010

by consalus:

I managed to trigger the bug in a non-trivial bit of xml parsing I was 
doing. Apologies that I don't have a test case, but the result of the 
CharData for
<TagName>Data Inside of Tag</TagName>
was
"TagNameide of Tag".
That is, it seemed like other parsing had overwritten the CharData.
Looking at the code, it seems that a slice from p.buf is being returned 
directly in xml.Parser.text(). When I changed xml.Parser.RawToken to
return CharData(data).Copy() instead of just CharData(data), the issue went 
away.


What is your $GOOS?  $GOARCH?
darwin 386

Which revision are you using?  (hg identify)
5f7ba03638b5+ tip

Please provide any additional information below.
@gopherbot

This comment has been minimized.

Copy link
Author

gopherbot commented Mar 18, 2010

Comment 1 by consalus:

Nevermind, this bug is invalid. I didn't see that the documentation notes that tokens
are 
only valid until the next call to "Token()".
Sorry about that.
@gopherbot

This comment has been minimized.

Copy link
Author

gopherbot commented Mar 19, 2010

Comment 2 by stephenm@golang.org:

Status changed to WorkingAsIntended.

@mikioh mikioh changed the title XML CharData returned is slice of internal buffer, so it gets overwritten encoding/xml: CharData returned is slice of internal buffer, so it gets overwritten Jan 9, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.