[PATCH] remote: check for negative array lengths before allocation