Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions core/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"errors"
"slices"
"sync"
"unsafe"

Expand Down Expand Up @@ -302,13 +303,7 @@ func (l *bufferList) exists(b *Buffer) bool {
l.RLock()
defer l.RUnlock()

for _, v := range l.list {
if b == v {
return true
}
}

return false
return slices.Contains(l.list, b)
}

// Flush clears the list and returns its previous contents.
Expand Down
2 changes: 1 addition & 1 deletion core/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Exit(c int) {
/*
Panic is identical to the builtin panic except it purges the session before calling panic.
*/
func Panic(v interface{}) {
func Panic(v any) {
Purge() // creates a new key so it is safe to recover from this panic
panic(v)
}
2 changes: 1 addition & 1 deletion examples/deadlock/x01/poc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func OpenEnclave(ctx context.Context) {
}

threads := 20
for i := 0; i < threads; i++ {
for range threads {
go func(ctx context.Context) {
for {
select {
Expand Down
2 changes: 1 addition & 1 deletion examples/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func SlowRandByte() byte {
}

// Do some example computation on this data.
for i := 0; i < n; i++ {
for i := range n {
parity = parity ^ buf.Bytes()[i]
}
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/awnumar/memguard

go 1.23.1
go 1.25.0

require (
github.com/awnumar/memcall v0.4.0
golang.org/x/crypto v0.41.0
golang.org/x/sys v0.35.0
github.com/awnumar/memcall v0.5.0
golang.org/x/crypto v0.50.0
golang.org/x/sys v0.44.0
lukechampine.com/frand v1.5.1
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
github.com/awnumar/memcall v0.4.0 h1:B7hgZYdfH6Ot1Goaz8jGne/7i8xD4taZie/PNSFZ29g=
github.com/awnumar/memcall v0.4.0/go.mod h1:8xOx1YbfyuCg3Fy6TO8DK0kZUua3V42/goA5Ru47E8w=
github.com/awnumar/memcall v0.5.0 h1:31zYqzH08fM1UBzr53ywXFvqVP4grhAIFFd1Pfd7Gtk=
github.com/awnumar/memcall v0.5.0/go.mod h1:5q5zKsL4XfYgqzCQEvUt9Dou4fEXWsn+tNrm1z1oYgQ=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w=
lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q=
2 changes: 1 addition & 1 deletion memguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Purge() {
/*
SafePanic wipes all it can before calling panic(v).
*/
func SafePanic(v interface{}) {
func SafePanic(v any) {
core.Panic(v)
}

Expand Down
1 change: 0 additions & 1 deletion signals_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows

package memguard

Expand Down
2 changes: 1 addition & 1 deletion stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestStreamReadWrite(t *testing.T) {
write(t, s, b)

// Read back four pages
for i := 0; i < 4; i++ {
for i := range 4 {
read(t, s, ref[i*os.Getpagesize():(i+1)*os.Getpagesize()], nil)
}

Expand Down
Loading