Clean up raw_prefix_list.

This also avoids a memory leak in the early error exit.
Protect against (unlikely) buffer overflow in run_script.