fix(ffi): validate struct return buffers (#36373)