Copy secure code from Coverity Scan