check reply type before casting, fixes a coredump.