github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/image/compression_nonoptimized.go (about)

     1  // Copyright 2022 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  //go:build windows || 386 || arm
     5  
     6  package image
     7  
     8  import (
     9  	"bytes"
    10  	"sync"
    11  )
    12  
    13  var decompressMu sync.Mutex
    14  
    15  func mustDecompress(compressed []byte) (data []byte, dtor func()) {
    16  	// Don't decompress more than one image at a time since it can consume lots of memory.
    17  	// Reconsider when/if we move mutation to the host process.
    18  	decompressMu.Lock()
    19  	buf := new(bytes.Buffer)
    20  	if err := decompressWriter(buf, compressed); err != nil {
    21  		panic(err)
    22  	}
    23  	return buf.Bytes(), decompressMu.Unlock
    24  }