Buggy code:
public void refresh ( ) { } public boolean setText ( String html ) { } public boolean setUrl ( String url ) { } public void stop ( ) { } void hookDOMListeners ( ) { } void hookDOMListeners ( nsIDOMEventTarget target , boolean isTop ) { } void unhookDOMListeners ( ) { } void unhookDOMListeners ( nsIDOMEventTarget target ) { } int QueryInterface ( int riid , int ppvObject ) { } int AddRef ( ) { } int Release ( ) { } int QueryReferent ( int riid , int ppvObject ) { } int GetInterface ( int riid , int ppvObject ) { } int GetWeakReference ( int ppvObject ) { } int OnStateChange ( int aWebProgress , int aRequest , int aStateFlags , int aStatus ) { } int OnProgressChange ( int aWebProgress , int aRequest , int aCurSelfProgress , int aMaxSelfProgress , int aCurTotalProgress , int aMaxTotalProgress ) { } int OnLocationChange ( int aWebProgress , int aRequest , int aLocation ) { } int OnStatusChange ( int aWebProgress , int aRequest , int aStatus , int aMessage ) { } int OnSecurityChange ( int aWebProgress , int aRequest , int state ) { } int SetStatus ( int statusType , int status ) { } int GetWebBrowser ( int aWebBrowser ) { } int SetWebBrowser ( int aWebBrowser ) { } int GetChromeFlags ( int aChromeFlags ) { } int SetChromeFlags ( int aChromeFlags ) { } int DestroyBrowserWindow ( ) { } int SizeBrowserTo ( int aCX , int aCY ) { } int ShowAsModal ( ) { } int IsWindowModal ( int retval ) { } int ExitModalEventLoop ( int aStatus ) { } int SetDimensions ( int flags , int x , int y , int cx , int cy ) { } int GetDimensions ( int flags , int x , int y , int cx , int cy ) { } int SetFocus ( ) { } int GetVisibility ( int aVisibility ) { } int SetVisibility ( int aVisibility ) { } int GetTitle ( int aTitle ) { } int SetTitle ( int aTitle ) { } int GetSiteWindow ( int aSiteWindow ) { } int FocusNextElement ( ) { } int FocusPrevElement ( ) { } int OnShowContextMenu ( int aContextFlags , int aEvent , int aNode ) { } int OnStartURIOpen ( int aURI , int retval ) { } int DoContent ( int aContentType , int aIsContentPreferred , int aRequest , int aContentHandler , int retval ) { } int IsPreferred ( int aContentType , int aDesiredContentType , int retval ) { } int CanHandleContent ( int aContentType , int aIsContentPreferred , int aDesiredContentType , int retval ) { } int GetLoadCookie ( int aLoadCookie ) { } int SetLoadCookie ( int aLoadCookie ) { } int GetParentContentListener ( int aParentContentListener ) { } int SetParentContentListener ( int aParentContentListener ) { } int OnShowTooltip ( int aXCoords , int aYCoords , int aTipText ) { } int OnHideTooltip ( ) { } int HandleEvent ( int event ) { nsIDOMEvent domEvent = new nsIDOMEvent ( event ) ; int type = XPCOM . nsEmbedString_new ( ) ; int rc = domEvent . GetType ( type ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; int length = XPCOM . nsEmbedString_Length ( type ) ; int buffer = XPCOM . nsEmbedString_get ( type ) ; char [ ] chars = new char [ length ] ; XPCOM . memmove ( chars , buffer , ( length * 2 ) ) ; String typeString = new String ( chars ) ; XPCOM . nsEmbedString_delete ( type ) ; if ( DOMEVENT_UNLOAD . equals ( typeString ) ) { int [ ] result = new int [ 1 ] ; <START_BUG> rc = domEvent . GetTarget ( result ) ; <END_BUG> if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; if ( ( result [ 0 ] ) == 0 ) Mozilla . error ( NS_NOINTERFACE ) ; nsIDOMEventTarget target = new nsIDOMEventTarget ( result [ 0 ] ) ; unhookDOMListeners ( target ) ; target . Release ( ) ; return XPCOM . NS_OK ; } if ( DOMEVENT_FOCUS . equals ( typeString ) ) { delegate . handleFocus ( ) ; return XPCOM . NS_OK ; } int [ ] result = new int [ 1 ] ; rc = domEvent . QueryInterface ( NS_IDOMMOUSEEVENT_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; if ( ( result [ 0 ] ) == 0 ) Mozilla . error ( NS_NOINTERFACE ) ; nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent ( result [ 0 ] ) ; result [ 0 ] = 0 ; if ( ( DOMEVENT_MOUSEOVER . equals ( typeString ) ) || ( DOMEVENT_MOUSEOUT . equals ( typeString ) ) ) { rc = domMouseEvent . GetRelatedTarget ( result ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; if ( ( result [ 0 ] ) != 0 ) { domMouseEvent . Release ( ) ; return XPCOM . NS_OK ; } } int [ ] aClientX = new int [ 1 ] ; int [ ] aClientY = new int [ 1 ] ; int [ ] aDetail = new int [ 1 ] ; rc = domMouseEvent . GetClientX ( aClientX ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; rc = domMouseEvent . GetClientY ( aClientY ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; rc = domMouseEvent . GetDetail ( aDetail ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ;

Fix:
rc = domEvent . GetCurrentTarget ( result ) ;