Browse Source

Bug 2166: Failure when selecting S3 protocol in Login dialog with non-existing .aws/credentials file

https://winscp.net/tracker/2166

Source commit: f857ba4e14cb4853e03855ddb8e01974b38f587b
Martin Prikryl 2 years ago
parent
commit
b8049eccbf
2 changed files with 6 additions and 3 deletions
  1. 1 1
      source/core/S3FileSystem.cpp
  2. 5 2
      source/forms/Login.cpp

+ 1 - 1
source/core/S3FileSystem.cpp

@@ -97,7 +97,7 @@ TStrings * GetS3Profiles()
   NeedS3Config();
   // S3 allegedly treats the section case-sensitivelly, but our GetS3ConfigValue (ReadString) does not,
   // so consistently we return case-insensitive list.
-  std::unique_ptr<TStrings> Result(CreateSortedStringList());
+  std::unique_ptr<TStrings> Result(new TStringList());
   if (S3ConfigFile.get() != NULL)
   {
     S3ConfigFile->ReadSections(Result.get());

+ 5 - 2
source/forms/Login.cpp

@@ -655,9 +655,12 @@ UnicodeString TLoginDialog::GetS3Profile()
 //---------------------------------------------------------------------
 void TLoginDialog::LoadS3Profiles()
 {
+  std::unique_ptr<TStringList> Items(new TStringList());
   std::unique_ptr<TStrings> Profiles(GetS3Profiles());
-  Profiles->Insert(0, GetS3GeneralName());
-  S3ProfileCombo->Items = Profiles.get();
+  Items->AddStrings(Profiles.get());
+  Items->Sort();
+  Items->Insert(0, GetS3GeneralName());
+  S3ProfileCombo->Items = Items.get();
 }
 //---------------------------------------------------------------------
 void __fastcall TLoginDialog::UpdateControls()