move NULL check into setBuffer