Skip to content

Fix size computation of imported lists

Uli Schlachter requested to merge psychon/xcbproto:incorrect-size into master

XFixes contains a CreateRegion 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

Merge request reports