pyldb: Avoid use-after-free in msg_diff()