bf: fix potential memory leaks.

When some of the error conditions were reached, memory wasn't
being free()'d. This patch fixes those cases.