fix leak when alt array has entry type != string

The double array walking is not that great, but it has the nice side effect
of adding the alternative paths only if the input is somewhat valid.