Browse Source

obj/btf: Fix size of Unknown variant

The size of Unknown should be ty_size, otherwise when it is encountered,
we never advance the cursor and it creates an infinite loop.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 3 years ago
parent
commit
4e1ce2534c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      aya/src/obj/btf/types.rs

+ 1 - 1
aya/src/obj/btf/types.rs

@@ -154,7 +154,7 @@ impl BtfType {
 
         use BtfType::*;
         match self {
-            Unknown => 0,
+            Unknown => ty_size,
             Fwd(_) | Const(_) | Volatile(_) | Restrict(_) | Ptr(_) | Typedef(_) | Func(_)
             | Float(_) => ty_size,
             Int(_, _) => ty_size + mem::size_of::<u32>(),