Fixed memory free bug on error in bs_put.

Free allocated memory in bs_put() on error.