]> git.proxmox.com Git - mirror_edk2.git/commitdiff
to fix
authorxgu3 <xgu3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 29 Mar 2007 06:04:36 +0000 (06:04 +0000)
committerxgu3 <xgu3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 29 Mar 2007 06:04:36 +0000 (06:04 +0000)
[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

EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c

index 0b5e538da7ac5898af8945d74fd115fbda1220a7..d55a153f9b9900c5656fed7b9cde0214305c9953 100644 (file)
@@ -138,11 +138,12 @@ Returns:
     ASSERT (0);\r
   }\r
 \r
     ASSERT (0);\r
   }\r
 \r
-  for (Pointer = Str; *(Pointer + Count); Pointer++) {\r
-    *Pointer = *(Pointer + Count);\r
+  if (Count != 0) {\r
+    for (Pointer = Str; *(Pointer + Count); Pointer++) {\r
+      *Pointer = *(Pointer + Count);\r
+    }\r
+    *Pointer = *(Pointer + Count);    \r
   }\r
   }\r
-\r
-  *Pointer = *(Pointer + Count);\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -632,13 +633,10 @@ Returns:
   CHAR16                            TempChar;\r
   DWORD                             LastError;\r
   UINTN                             Count;\r
   CHAR16                            TempChar;\r
   DWORD                             LastError;\r
   UINTN                             Count;\r
-  BOOLEAN                           TrailingDash;\r
   BOOLEAN                           LoopFinish;\r
   UINTN                             InfoSize;\r
   EFI_FILE_INFO                     *Info;\r
 \r
   BOOLEAN                           LoopFinish;\r
   UINTN                             InfoSize;\r
   EFI_FILE_INFO                     *Info;\r
 \r
-  TrailingDash = FALSE;\r
-\r
   //\r
   // Check for obvious invalid parameters.\r
   //\r
   //\r
   // Check for obvious invalid parameters.\r
   //\r
@@ -667,10 +665,27 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  //\r
+  // Init local variables\r
+  //\r
   PrivateFile     = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
   PrivateRoot     = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);\r
   NewPrivateFile  = NULL;\r
 \r
   PrivateFile     = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
   PrivateRoot     = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);\r
   NewPrivateFile  = NULL;\r
 \r
+  //\r
+  // Allocate buffer for FileName as the passed in FileName may be read only\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  StrSize (FileName),\r
+                  &TempFileName\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return  Status;\r
+  }\r
+  StrCpy (TempFileName, FileName);\r
+  FileName = TempFileName;\r
+\r
   //\r
   // BUGBUG: assume an open of root\r
   // if current location, return current data\r
   //\r
   // BUGBUG: assume an open of root\r
   // if current location, return current data\r
@@ -686,7 +701,6 @@ OpenRoot:
   }\r
 \r
   if (FileName[StrLen (FileName) - 1] == L'\\') {\r
   }\r
 \r
   if (FileName[StrLen (FileName) - 1] == L'\\') {\r
-    TrailingDash                        = TRUE;\r
     FileName[StrLen (FileName) - 1]  = 0;\r
   }\r
 \r
     FileName[StrLen (FileName) - 1]  = 0;\r
   }\r
 \r
@@ -1067,10 +1081,7 @@ OpenRoot:
   }\r
 \r
 Done: ;\r
   }\r
 \r
 Done: ;\r
-  if (TrailingDash) {\r
-    FileName[StrLen (FileName) + 1]  = 0;\r
-    FileName[StrLen (FileName)]      = L'\\';\r
-  }\r
+  gBS->FreePool (FileName);\r
 \r
   if (EFI_ERROR (Status)) {\r
     if (NewPrivateFile) {\r
 \r
   if (EFI_ERROR (Status)) {\r
     if (NewPrivateFile) {\r