fix: fixes out of bounds crash when waku2 is not set (#1895)

This commit is contained in:
Alvaro Revuelta 2023-08-08 16:22:53 +02:00 committed by GitHub
parent c8446aebca
commit 03363f1bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -76,6 +76,9 @@ func waku2*(record: TypedRecord): Option[CapabilitiesBitfield] =
if field.isNone():
return none(CapabilitiesBitfield)
if field.get().len != 1:
return none(CapabilitiesBitfield)
some(CapabilitiesBitfield(field.get()[0]))
proc supportsCapability*(r: Record, cap: Capabilities): bool =