Fix size computation of imported lists

XFixes contains a CreateRegion request:

   <request name="CreateRegion" opcode="5">
     <field type="REGION"    name="region" />
     <list  type="RECTANGLE" name="rectangles" />
   </request>

This request contains a list of type RECTANGLE. This struct comes from
xproto and is thus not contained in xfixes itself.

Normal "Struct"s have their resolve() method called early, because they
appear in the module itself. However, in the CreateRegion case, this
struct is imported and thus does not get resolved. Instead, ListType's
resolve() method calls self.member.resolve(module). Thus, only at this
point is the struct resolved.

Why is this important? Struct.resolve() is the same as
ComplexType.resolve() and this function does self.calc_size() at the
end. Thus, only after the struct was resolved is its size known. Before
that, the size is just set to 0 (this happens in ComplexType.__init__).

However, ListType.__init__ already computes its size member based on its
member. At this point, this is still 0 so the list ends up believing its
size to be zero.

Fix this by recomputing self.size in ListType.resolve().

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2019-12-01 14:23:57 +01:00
parent 7540642b34
commit 3cc42f6d23

View file

@ -333,6 +333,9 @@ class ListType(Type):
self.member.resolve(module)
self.expr.resolve(module, self.parents)
# resolve() could have changed the size (ComplexType starts with size 0)
self.size = self.member.size if self.member.fixed_size() else None
self.required_start_align = self.member.required_start_align
# Find my length field again. We need the actual Field object in the expr.