I actually found the problem, and it's got nothing to do with what I do with the variable. It's actually what I was doing as a result of an if test on the variable i.e. the piece of code i was working on was causing the problem. I've now fixed it so it won't happen again
To explain more, I'd set a WInEvent hook to catch changes to the History part of a convo window. Thing is, it was also catching the 'Sign in as someone else' dialog, which obviously has a totally different structure. Add an oversight in error-checking, and presto! crashes galore.