Fix segfault when writing config