[#2170] use correct string length when copying resource context