fix two nested loops sharing the same control variable, plug two memory leaks and be consistent about error values returned to the caller
fix two nested loops sharing the same control variable, plug two memory
leaks and be consistent about error values returned to the caller

orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars