View Issue Details

IDProjectCategoryView StatusLast Update
0000414Far ManagerEditorpublic2007-12-12 14:21
Reporteralexmitin Assigned Tovskirdin  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Fixed in Version1.80 alpha 1 
Summary0000414: Handle leak in FileEditor::LoadFile()
DescriptionFile: fileedit.cpp
Line: 1490
Function: FileEditor::LoadFile()
Context:
int FileEditor::LoadFile(const wchar_t *Name,int &UserBreak)
{
...
   HANDLE hEdit = apiCreateFile(
...
   int EditHandle=_open_osfhandle((intptr_t)hEdit,O_BINARY);
   if ( EditHandle == -1 )
      return FALSE; <==[bug1]==

    if ( (EditFile=fdopen(EditHandle,"rb")) == NULL )
      return FALSE; <==[bug2]==
...
}

Observations
============
1) Bug1: If _open_osfhandle() returns -1 the "hEdit" file handle is not closed.
2) Bug2: If fdopen() returns NULL the "EditHandle" handle is not closed.

The proposed fix:

   int EditHandle=_open_osfhandle((intptr_t)hEdit,O_BINARY);
   if ( EditHandle == -1 )
   {
      CloseHandle(hEdit); // fix for bug1
      return FALSE;
    }

    if ( (EditFile=fdopen(EditHandle,"rb")) == NULL )
    {
      _close(EditFile); // fix for bug2
      return FALSE;
    }
Additional InformationFAR 1.80.0.382
TagsNo tags attached.
Build383

Activities

vskirdin

2007-12-05 07:30

administrator   bugnote:0000955

после 382

alexmitin

2007-12-12 12:02

reporter   bugnote:0001017

Verified in FAR 1.80.0.389.

Issue History

Date Modified Username Field Change
2007-12-04 21:14 alexmitin New Issue
2007-12-04 21:14 alexmitin Status new => assigned
2007-12-04 21:14 alexmitin Assigned To => vskirdin
2007-12-05 07:30 vskirdin Note Added: 0000955
2007-12-05 07:30 vskirdin Status assigned => feedback
2007-12-12 12:02 alexmitin Status feedback => resolved
2007-12-12 12:02 alexmitin Resolution open => fixed
2007-12-12 12:02 alexmitin Note Added: 0001017
2007-12-12 14:21 vskirdin Build => 383
2007-12-12 14:21 vskirdin Status resolved => closed
2007-12-12 14:21 vskirdin Fixed in Version => 1.80 alpha 1