fix use after free
This fixes an invalid read showing up in valgrind when opening some conversations in Pidgin and the closing Pidgin.
The code was introduced with /r/1342. It looks pretty straightforward so I hope I'm not messing with the fixes that were done in that RR.
Testing Done:
Started Pidgin in valgrind, opened some conversations and closed Pidgin again. No more invalid reads are shown.
Reviewed at https://reviews.imfreedom.org/r/1488/