Adding check before cleaning the buffer
Merge pull request #1 from BertrandVillien/patch-1

Adding check before cleaning the buffer