common: Fix possible crash in mkdir_with_parents()