fix crash in window.open in some cases