Merge "diag: Fix incorrect handling of buffers"