`create_statistics_for_filename()` needs to either always succeed, or you need to check for `stats != NULL` before moving on here.