check buffer pointer for NULL