By the way, handle->realpath is leaked when the call to malloc() a few lines down fails.