mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
channeldb: copy value from boltdb's Get instead of using it directly
This can cause an intermittent panic otherwise if bbolt remaps itself via munmap and mmap. From bbolt's documentation: * Byte slices returned from Bolt are only valid during a transaction. Once the transaction has been committed or rolled back then the memory they point to can be reused by a new page or can be unmapped from virtual memory and you'll see an unexpected fault address panic when accessing it.
This commit is contained in:
parent
b31640e6b0
commit
2e3246aafe
@ -1254,11 +1254,13 @@ func (c *ChannelStateDB) GetChannelOpeningState(outPoint []byte) ([]byte, error)
|
||||
return ErrChannelNotFound
|
||||
}
|
||||
|
||||
serializedState = bucket.Get(outPoint)
|
||||
if serializedState == nil {
|
||||
stateBytes := bucket.Get(outPoint)
|
||||
if stateBytes == nil {
|
||||
return ErrChannelNotFound
|
||||
}
|
||||
|
||||
serializedState = append(serializedState, stateBytes...)
|
||||
|
||||
return nil
|
||||
}, func() {
|
||||
serializedState = nil
|
||||
|
Loading…
Reference in New Issue
Block a user