sanm: Check dimensions before use