Add further checks to ensure that the 'type' value does not cause issues if it is 'nil'

This commit is contained in:
gwillcox-r7 2020-08-04 14:32:21 -05:00
parent c196d9b733
commit 307dcc9b19
No known key found for this signature in database
GPG Key ID: D35E05C0F2B81E83
1 changed files with 7 additions and 0 deletions

View File

@ -48,6 +48,13 @@ class Message
raise ParseError unless (!length.nil? && length >= 4)
# If we didn't read any bytes and startup was not set, then type will be nil, so don't continue.
unless startup
if type.nil?
return ParseError
end
end
# initialize buffer
buffer = Buffer.of_size(startup ? length : 1+length)
buffer.write(type) unless startup