From 5a03fe572f8076dcd78d508af979915cae76c71b Mon Sep 17 00:00:00 2001 From: nsa Date: Mon, 3 Feb 2020 20:43:22 -0500 Subject: [PATCH] lnwire: move zero-length queryBody check to zlib case --- lnwire/query_short_chan_ids.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lnwire/query_short_chan_ids.go b/lnwire/query_short_chan_ids.go index 91f25227..76729364 100644 --- a/lnwire/query_short_chan_ids.go +++ b/lnwire/query_short_chan_ids.go @@ -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.