diff options
author | xgu3 <xgu3@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-29 06:04:36 +0000 |
---|---|---|
committer | xgu3 <xgu3@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-29 06:04:36 +0000 |
commit | cb360b2656f4ca06b0b216dd7b9933312abeb786 (patch) | |
tree | cf50c1b09dfb07ccbec363184a5062ea53748698 | |
parent | 4b2e068430507d4ba1ec330e1665b8d7b45771ac (diff) | |
download | edk2-cb360b2656f4ca06b0b216dd7b9933312abeb786.zip edk2-cb360b2656f4ca06b0b216dd7b9933312abeb786.tar.gz edk2-cb360b2656f4ca06b0b216dd7b9933312abeb786.tar.bz2 |
to fix
[NT32] Emulator can't run when built with /O1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2512 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c index 0b5e538..d55a153 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c @@ -138,11 +138,12 @@ Returns: ASSERT (0);
}
- for (Pointer = Str; *(Pointer + Count); Pointer++) {
- *Pointer = *(Pointer + Count);
+ if (Count != 0) {
+ for (Pointer = Str; *(Pointer + Count); Pointer++) {
+ *Pointer = *(Pointer + Count);
+ }
+ *Pointer = *(Pointer + Count);
}
-
- *Pointer = *(Pointer + Count);
}
@@ -632,13 +633,10 @@ Returns: CHAR16 TempChar;
DWORD LastError;
UINTN Count;
- BOOLEAN TrailingDash;
BOOLEAN LoopFinish;
UINTN InfoSize;
EFI_FILE_INFO *Info;
- TrailingDash = FALSE;
-
//
// Check for obvious invalid parameters.
//
@@ -667,11 +665,28 @@ Returns: return EFI_INVALID_PARAMETER;
}
+ //
+ // Init local variables
+ //
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
NewPrivateFile = NULL;
//
+ // Allocate buffer for FileName as the passed in FileName may be read only
+ //
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ StrSize (FileName),
+ &TempFileName
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ StrCpy (TempFileName, FileName);
+ FileName = TempFileName;
+
+ //
// BUGBUG: assume an open of root
// if current location, return current data
//
@@ -686,7 +701,6 @@ OpenRoot: }
if (FileName[StrLen (FileName) - 1] == L'\\') {
- TrailingDash = TRUE;
FileName[StrLen (FileName) - 1] = 0;
}
@@ -1067,10 +1081,7 @@ OpenRoot: }
Done: ;
- if (TrailingDash) {
- FileName[StrLen (FileName) + 1] = 0;
- FileName[StrLen (FileName)] = L'\\';
- }
+ gBS->FreePool (FileName);
if (EFI_ERROR (Status)) {
if (NewPrivateFile) {
|