lnwire: move zero-length queryBody check to zlib case
This commit is contained in:
parent
7b9e0c889e
commit
5a03fe572f
@ -148,13 +148,6 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
|||||||
// as that was just the encoding type.
|
// as that was just the encoding type.
|
||||||
queryBody = queryBody[1:]
|
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
|
// Otherwise, depending on the encoding type, we'll decode the encode
|
||||||
// short channel ID's in a different manner.
|
// short channel ID's in a different manner.
|
||||||
switch encodingType {
|
switch encodingType {
|
||||||
@ -210,6 +203,13 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
|||||||
zlibDecodeMtx.Lock()
|
zlibDecodeMtx.Lock()
|
||||||
defer zlibDecodeMtx.Unlock()
|
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
|
// Before we start to decode, we'll create a limit reader over
|
||||||
// the current reader. This will ensure that we can control how
|
// the current reader. This will ensure that we can control how
|
||||||
// much memory we're allocating during the decoding process.
|
// much memory we're allocating during the decoding process.
|
||||||
|
Loading…
Reference in New Issue
Block a user