Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354051 - textInputListener from OutlinePage is unsafe
Summary: textInputListener from OutlinePage is unsafe
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: SR2   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 345388 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-08-05 15:33 EDT by Samantha Chan CLA
Modified: 2017-09-19 17:32 EDT (History)
5 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samantha Chan CLA 2011-08-05 15:33:01 EDT
In this code here:

	textInputListener = new ITextInputListener() {
			public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
				try {
					xtextDocument.removeModelListener(modelListener);
					xtextDocument = XtextDocumentUtil.get(newInput);
					xtextDocument.addModelListener(modelListener);
					scheduleRefresh();
				} catch (Throwable t) {
					LOG.error("Error refreshing outline", t);
				}
			}
			
			public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
			}
		};

XTextDocumentUtil.get(newInput) can return null as the xtextDocument.  We use the XtextDocument object without checking the return value, causing NPE to happen.
Comment 1 Samantha Chan CLA 2011-08-10 11:41:55 EDT
Is it possible to target this for the next 2.0 SR?

Thanks!
Comment 2 Sebastian Zarnekow CLA 2011-08-16 17:11:15 EDT
Scheduled for 2.1
Comment 3 Jan Koehnlein CLA 2011-08-29 12:01:52 EDT
*** Bug 345388 has been marked as a duplicate of this bug. ***
Comment 4 Jan Koehnlein CLA 2011-08-30 11:07:59 EDT
Added a couple of NPE guards. 

I'd like to provide a test, too, but I can't figure out how to reproduce the NPE. Can you give me a hint?
Comment 5 Sebastian Zarnekow CLA 2011-09-30 04:41:02 EDT
(In reply to comment #4)
> I'd like to provide a test, too, but I can't figure out how to reproduce the
> NPE. Can you give me a hint?

Ping.
Comment 6 Jan Koehnlein CLA 2011-10-26 09:32:51 EDT
As there was no hint how to test this, I am closing this without a test.
Comment 7 Karsten Thoms CLA 2017-09-19 17:21:14 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 8 Karsten Thoms CLA 2017-09-19 17:32:38 EDT
Closing all bugs that were set to RESOLVED before Neon.0