View Issue Details

IDProjectCategoryView StatusLast Update
0000404Far ManagerSettingspublic2007-12-03 14:42
Reporteralexmitin Assigned Toalexy  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Fixed in Version1.80 alpha 1 
Summary0000404: Handle leak in CopyKeyTree()
DescriptionThere is a handle leak in the CopyKeyTree() function.

Steps to reproduce:
1) Put a breakpoint in CopyKeyTree() function.
2) Start FAR under debugger with the following command line:

     FAR.exe -U testuser

3) Step through the code and watch the value of "hDestKey" variable.

File: registry.cpp
Line: 515
Function: CopyKeyTree()
Context:
int CopyKeyTree(const wchar_t *Src,const wchar_t *Dest,const wchar_t *Skip)
{
HKEY hSrcKey,hDestKey;
...
DWORD Disposition;
if(RegCreateKeyExW(hRegRootKey,Dest,0,NULL,0,KEY_WRITE,NULL,&hDestKey,&Disposition)!=ERROR_SUCCESS)
{
...
  for (I=0;;I++)
  {
...
if(RegCreateKeyExW(hRegRootKey,strDestKeyName,0,NULL,0,KEY_WRITE,NULL,&hDestKey,&Disposition)!=ERROR_SUCCESS)
      break;
CopyKeyTree(strSrcKeyName,strDestKeyName);
  }
  CloseRegKey(hSrcKey);
  CloseRegKey(hDestKey);
  return(TRUE);
}

Sample Call Stack
-----------------
*1 Far.exe!CopyKeyTree(const wchar_t * Src=0x02fc0fa8, const wchar_t * Dest=0x02fc4f80, const wchar_t * Skip=0x00000000)
 2 Far.exe!CopyKeyTree(const wchar_t * Src=0x02f72fa8, const wchar_t * Dest=0x02f78f80, const wchar_t * Skip=0x00000000)
 3 Far.exe!CopyKeyTree(const wchar_t * Src=0x02f5efa8, const wchar_t * Dest=0x02f62fa8, const wchar_t * Skip=0x00000000)
 4 Far.exe!CopyKeyTree(const wchar_t * Src=0x00538ba4, const wchar_t * Dest=0x02f4cfa8, const wchar_t * Skip=0x005393e8)
 5 Far.exe!CopyGlobalSettings()
 6 Far.exe!wmain(int Argc=3, wchar_t * * Argv=0x02ddef68)
 7 Far.exe!__tmainCRTStartup()
 8 Far.exe!wmainCRTStartup()


Observations
============
The first call to RegCreateKeyExW() assigns the value to "hDestKey".
The second call to RegCreateKeyExW() overrides the value of "hDestKey" without closing it first.
Additional InformationFAR 1.80.0.373
TagsNo tags attached.
Build376

Activities

alexy

2007-12-03 14:42

administrator   bugnote:0000939

376

Issue History

Date Modified Username Field Change
2007-12-03 01:31 alexmitin New Issue
2007-12-03 01:57 vskirdin Status new => assigned
2007-12-03 01:57 vskirdin Assigned To => vskirdin
2007-12-03 14:05 alexy Assigned To vskirdin => alexy
2007-12-03 14:42 alexy Build => 376
2007-12-03 14:42 alexy Status assigned => closed
2007-12-03 14:42 alexy Note Added: 0000939
2007-12-03 14:42 alexy Resolution open => fixed
2007-12-03 14:42 alexy Fixed in Version => 1.80 alpha 1