Fixed closing zlib decompressor in error case. Added missing header.

This commit is contained in:
Sascha L. Teichmann 2014-09-10 17:33:13 +02:00
parent 0ff87c1d22
commit 26aabeb6d5
3 changed files with 8 additions and 2 deletions

View File

@ -61,10 +61,11 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int) (db *DecodedBlock, e
}
var mapContent []byte
if mapContent, err = ioutil.ReadAll(zr); err != nil {
mapContent, err = ioutil.ReadAll(zr)
zr.Close()
if err != nil {
return
}
zr.Close()
if uncompressedLen != len(mapContent) {
err = ErrMapContentSizeMismatch

View File

@ -1,3 +1,7 @@
// Copyright 2014 by Sascha L. Teichmann
// Use of this source code is governed by the MIT license
// that can be found in the LICENSE file.
package main
import (

View File

@ -83,6 +83,7 @@ func main() {
fmt.Printf("num of blocks: %d\n", numBlocks)
fmt.Printf("num of bytes: %d\n", bytesTotal)
fmt.Println("uses block versions:")
for version, count := range versions {
fmt.Printf("%d: %d\n", version, count)
}