Cherrypick buffer fix from vanir gerrit