Check buffer size before checking buffer data
If the expected size is bigger than the actual buffer size, it would memcmp random memory which could lead to crashes instead of proper error reporting.
If the expected size is bigger than the actual buffer size, it would memcmp random memory which could lead to crashes instead of proper error reporting.