[1.2.2] Segfault in unserialize()

Backport to 1.2.2