//TEMPTEMP
ULONG UsedBufferSize;
TempBuffer = ExAllocatePoolWithTag(NonPagedPool, Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ if (TempBuffer == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
LastLCN = 0;
CurrentOffset = 0;
if (*DataRun == 0)
{
+ ExFreePoolWithTag(TempBuffer, TAG_NTFS);
return AlreadyRead;
}
CurrentOffset = 0;
// This will be rewritten in the next iteration to just use the DataRuns MCB directly
- TempBuffer = ExAllocatePoolWithTag(NonPagedPool, Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ TempBuffer = ExAllocatePoolWithTag(NonPagedPool, Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ if (TempBuffer == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
ConvertLargeMCBToDataRuns(&Context->DataRunsMCB,
TempBuffer,
// (it may require increasing the allocation size).
DataRunStartLCN = -1;
DPRINT1("FIXME: Writing to sparse files is not supported yet!\n");
- return STATUS_NOT_IMPLEMENTED;
+ Status = STATUS_NOT_IMPLEMENTED;
+ goto Cleanup;
}
// Have we reached the data run we're trying to write to?
// (Presently, this code will rarely be reached, the write will usually have already failed by now)
// [We can reach here by creating a new file record when the MFT isn't large enough]
DPRINT1("FIXME: Master File Table needs to be enlarged.\n");
- return STATUS_END_OF_FILE;
+ Status = STATUS_END_OF_FILE;
+ goto Cleanup;
}
CurrentOffset += DataRunLength * Vcb->NtfsInfo.BytesPerCluster;
Context->CacheRunLastLCN = LastLCN;
Context->CacheRunCurrentOffset = CurrentOffset;
- return Status;
+ goto Cleanup;
}
Length -= WriteLength;
if (DataRunStartLCN == -1)
{
DPRINT1("FIXME: Don't know how to write to sparse files yet! (DataRunStartLCN == -1)\n");
- return STATUS_NOT_IMPLEMENTED;
+ Status = STATUS_NOT_IMPLEMENTED;
+ goto Cleanup;
}
else
{
{
// Failed sanity check.
DPRINT1("Encountered EOF before expected!\n");
- return STATUS_END_OF_FILE;
+ Status = STATUS_END_OF_FILE;
+ goto Cleanup;
}
break;
}
} // end while (Length > 0) [more data to write]
- // TEMPTEMP
- if (Context->pRecord->IsNonResident)
- ExFreePoolWithTag(TempBuffer, TAG_NTFS);
-
Context->CacheRun = DataRun;
Context->CacheRunOffset = Offset + *RealLengthWritten;
Context->CacheRunStartLCN = DataRunStartLCN;
Context->CacheRunLastLCN = LastLCN;
Context->CacheRunCurrentOffset = CurrentOffset;
+Cleanup:
+ // TEMPTEMP
+ if (Context->pRecord->IsNonResident)
+ ExFreePoolWithTag(TempBuffer, TAG_NTFS);
+
return Status;
}