Bug 49851

Summary: JNI Registry.deleteKey and Registry.deleteValue corrupt Windows registry
Product: Tomcat Native Reporter: vadim.tsing
Component: LibraryAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P2    
Version: 1.1.20   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description vadim.tsing 2010-08-31 13:18:32 UTC
The issue was discovered in version 1.1.20 of Tomcat Native libraries while trying to use Registry class on Windows XP.
Unlike other methods, deleteKey() and deleteValue() do not initialize parameters that are passed to Windows APIs.
Typical initialization of string parameters consists of 

TCN_ALLOC_WSTRING(name);
...
TCN_INIT_WSTRING(name);
...
TCN_FREE_WSTRING(name);

However, the two methods listed above do not call TCN_INIT_WSTRING. Without this, the Windows API SHDeleteKeyW() is called with a null (0) parameter that causes Windows registry corruption. In my case (before issue was diagnosed) it resulted in the need to re-install Windows (twice) :-(.