add buffer pointer checks.