lib/util/util.c: move null-check before use