This is a bug fix for something that happened when I messed up the cfg[] somewhere else, but if cfg[] has a single entry that's NULL, this code loses because it doesn't catch it.  The test is fast enough I thought I'd leave the test in place.