Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334661 - Use of uninitialized variable in os_custom.cpp (wpf)
Summary: Use of uninitialized variable in os_custom.cpp (wpf)
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-18 10:39 EST by Niels Thykier CLA
Modified: 2011-01-18 11:34 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niels Thykier CLA 2011-01-18 10:39:14 EST
Build Identifier: 

Hi

cppcheck (1.44) reports a number of possible usage of uninitialized variables in org.eclipse.swt/Eclipse SWT PI/wpf/library/os_custom.cpp.

[os_custom.cpp:176]: (error) Uninitialized variable: env
[os_custom.cpp:228]: (error) Uninitialized variable: env
[os_custom.cpp:289]: (error) Uninitialized variable: env
[os_custom.cpp:322]: (error) Uninitialized variable: env
[os_custom.cpp:373]: (error) Uninitialized variable: env
[os_custom.cpp:469]: (error) Uninitialized variable: env
[os_custom.cpp:774]: (error) Uninitialized variable: env
[os_custom.cpp:836]: (error) Uninitialized variable: env
[os_custom.cpp:865]: (error) Uninitialized variable: env
[os_custom.cpp:998]: (error) Uninitialized variable: env

It is triggered by code like this:
...
		JNIEnv* env;
...
#ifdef JNI_VERSION_1_2
		if (IS_JNI_1_2) {
			jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
		}
#endif
		if (env == NULL) {
...

Here env is only initialized if JNI_VERSION_1_2 is defined.  I have a feeling that this is usually the case, still I thought I would mention it.

Note: I have not manually verified all of them.

~Niels



Reproducible: Always
Comment 1 Niels Thykier CLA 2011-01-18 10:48:42 EST
Make that "Here env is only initialized if JNI_VERSION_1_2is defined  and IS_JNI_1_2 is a truth value". :)

~Niels
Comment 2 Felipe Heidrich CLA 2011-01-18 11:34:14 EST
Read the entire method,
if env == NULL it gets initialized by jvm->AttachCurrentThread((void **)&env, NULL); (maybe the cppcheck tool is failing to detected that ?)

The code looks okay to me. 
Closing this as invalid (note also that we are no longer working on the WPF port). Thank you.