I found this in our multimaster project on PostgreSQL 11.5. It is 
difficult to reproduce this error, but I will try to do it if necessary.
The rest of a continuation WAL-record can exactly match the block size. 
In this case, we need to switch targetPagePtr to the next block before 
calculating the starting point of the next WAL-record.
See the patch in attachment for the bug fix.
-- 
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company