rds: avoid potential stack overflow