Fix segfault when recording directory listing (Marcin Junczys-Dowmunt).