fix a potential dangling pointer
Merge remote-tracking branch 'upstream/master' into win32