33f5799a81
Pull a copy of the filename string before calling basename(). Change the loop to not return on its own, so we can put a free() statement at the bottom.