mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-21 14:10:35 +02: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:
@@ -1254,11 +1254,13 @@ func (c *ChannelStateDB) GetChannelOpeningState(outPoint []byte) ([]byte, error)
|
|||||||
return ErrChannelNotFound
|
return ErrChannelNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
serializedState = bucket.Get(outPoint)
|
stateBytes := bucket.Get(outPoint)
|
||||||
if serializedState == nil {
|
if stateBytes == nil {
|
||||||
return ErrChannelNotFound
|
return ErrChannelNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serializedState = append(serializedState, stateBytes...)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, func() {
|
}, func() {
|
||||||
serializedState = nil
|
serializedState = nil
|
||||||
|
Reference in New Issue
Block a user