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

compress/gzip: Close on zero value of Reader panics #9787

Closed
kortschak opened this issue Feb 6, 2015 · 1 comment
Closed

compress/gzip: Close on zero value of Reader panics #9787

kortschak opened this issue Feb 6, 2015 · 1 comment

Comments

@kortschak
Copy link
Contributor

Using Go version 1.4.1

Run the program at http://play.golang.org/p/Sd2Vt1Nucr

package main

import "compress/gzip"

func main() {
    var gz gzip.Reader
    gz.Close()
}

Expect: no output.
Get: panic: runtime error: invalid memory address or nil pointer dereference

Since the addition of Reset to gzip.Reader it is possible to use a gzip.Reader value that was not created by a call to gzip.NewReader, allowing lazy initialisation of the Reader. If the Reader has never been Reset the Close call attempts to close the underlying flate.decompressor, resulting in a nil pointer dereference.

@kortschak
Copy link
Contributor Author

Closing after discussion in code-review.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants