Fixed memory free bug on error in bs_put.