Issue #988: Use safe string functions for copying values