Index: sdk/tools/cabman/cabinet.cxx =================================================================== --- sdk/tools/cabman/cabinet.cxx (revision 71259) +++ sdk/tools/cabman/cabinet.cxx (working copy) @@ -1162,6 +1162,7 @@ if (Offset == INVALID_SET_FILE_POINTER) { DPRINT(MIN_TRACE, ("SetFilePointer() failed, error code is %u.\n", (UINT)GetLastError())); + FreeMemory(Buffer); CloseFile(DestFile); return CAB_STATUS_INVALID_CAB; } @@ -1252,8 +1253,11 @@ if (CFData.UncompSize == 0) { if (strlen(DiskNext) == 0) + { + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_NOFILE; - + } /* CloseCabinet() will destroy all file entries so in case FileName refers to the FileName field of a CFFOLDER_NODE structure, we have to save a copy of the filename */ @@ -1267,7 +1271,11 @@ Status = Open(); if (Status != CAB_STATUS_SUCCESS) + { + CloseFile(DestFile); + FreeMemory(Buffer); return Status; + } /* The first data block of the file will not be found as it is located in the previous file */ @@ -1275,6 +1283,8 @@ if (Status == CAB_STATUS_NOFILE) { DPRINT(MID_TRACE, ("Cannot locate file (%u).\n", (UINT)Status)); + CloseFile(DestFile); + FreeMemory(Buffer); return Status; } @@ -1289,6 +1299,8 @@ FILE_BEGIN) == INVALID_SET_FILE_POINTER ) { DPRINT(MIN_TRACE, ("SetFilePointer() failed, error code is %u.\n", (UINT)GetLastError())); + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_INVALID_CAB; } #else @@ -1295,6 +1307,8 @@ if (fseek(FileHandle, (off_t)File->DataBlock->AbsoluteOffset, SEEK_SET) != 0) { DPRINT(MIN_TRACE, ("fseek() failed.\n")); + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_INVALID_CAB; } #endif @@ -1329,6 +1343,8 @@ { DPRINT(MID_TRACE, ("BytesToWrite (%u) != CFData.UncompSize (%d)\n", (UINT)BytesToWrite, CFData.UncompSize)); + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_INVALID_CAB; } @@ -1364,6 +1380,8 @@ FILE_BEGIN) == INVALID_SET_FILE_POINTER ) { DPRINT(MIN_TRACE, ("SetFilePointer() failed, error code is %u.\n", (UINT)GetLastError())); + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_INVALID_CAB; } #else @@ -1371,6 +1389,8 @@ CurrentDataNode->Data.CompSize, SEEK_SET) != 0) { DPRINT(MIN_TRACE, ("fseek() failed.\n")); + CloseFile(DestFile); + FreeMemory(Buffer); return CAB_STATUS_INVALID_CAB; } #endif