Replace with security-enhanced function for MSVC