fix buffer leak