strings: fix memory handling in first non-repeating char