Fix unsafe allocation