mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
lnwire: move zero-length queryBody check to zlib case
This commit is contained in:
@@ -148,13 +148,6 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
// as that was just the encoding type.
|
||||
queryBody = queryBody[1:]
|
||||
|
||||
// At this point, if there's no body remaining, then only the encoding
|
||||
// type was specified, meaning that there're no further bytes to be
|
||||
// parsed.
|
||||
if len(queryBody) == 0 {
|
||||
return encodingType, nil, nil
|
||||
}
|
||||
|
||||
// Otherwise, depending on the encoding type, we'll decode the encode
|
||||
// short channel ID's in a different manner.
|
||||
switch encodingType {
|
||||
@@ -210,6 +203,13 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
zlibDecodeMtx.Lock()
|
||||
defer zlibDecodeMtx.Unlock()
|
||||
|
||||
// At this point, if there's no body remaining, then only the encoding
|
||||
// type was specified, meaning that there're no further bytes to be
|
||||
// parsed.
|
||||
if len(queryBody) == 0 {
|
||||
return encodingType, nil, nil
|
||||
}
|
||||
|
||||
// Before we start to decode, we'll create a limit reader over
|
||||
// the current reader. This will ensure that we can control how
|
||||
// much memory we're allocating during the decoding process.
|
||||
|
Reference in New Issue
Block a user