lower() returns a new string which should be stored and not just referenced. Valgrind shows invalid reads if you just store the ref.