fix memory leak in scandir.c