[#2212] CID60656:

freed bbuf before it leaves scope
[#2212] CID44260:

don't dereference possibly null pointer