Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: chrome/browser/password_manager/native_backend_libsecret.cc

Issue 891463002: Fill empty fields from keyring result with default values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/native_backend_libsecret.cc
diff --git a/chrome/browser/password_manager/native_backend_libsecret.cc b/chrome/browser/password_manager/native_backend_libsecret.cc
index 17051f9ccbf82d1de69850dfb255c26b2c3ffcc0..7cc94af040e41ea046b524cb3a4758dfdc7e0aff 100644
--- a/chrome/browser/password_manager/native_backend_libsecret.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret.cc
@@ -19,6 +19,10 @@ using autofill::PasswordForm;
using base::UTF8ToUTF16;
using base::UTF16ToUTF8;
+namespace {
+const char kEmptyString[] = "";
+}
+
typeof(&::secret_password_store_sync)
LibsecretLoader::secret_password_store_sync;
typeof(&::secret_service_search_sync)
@@ -119,14 +123,17 @@ const SecretSchema kLibsecretSchema = {
{"application", SECRET_SCHEMA_ATTRIBUTE_STRING},
{nullptr, SECRET_SCHEMA_ATTRIBUTE_STRING}}};
-char* GetStringFromAttributes(GHashTable* attrs, const char* keyname) {
- return static_cast<char*>(g_hash_table_lookup(attrs, keyname));
+const char* GetStringFromAttributes(GHashTable* attrs, const char* keyname) {
+ gpointer value = g_hash_table_lookup(attrs, keyname);
+ return value ? static_cast<char*>(value) : kEmptyString;
}
uint32_t GetUintFromAttributes(GHashTable* attrs, const char* keyname) {
- char* value = static_cast<char*>(g_hash_table_lookup(attrs, keyname));
+ gpointer value = g_hash_table_lookup(attrs, keyname);
+ if (!value)
+ return uint32_t();
uint32_t result;
- bool value_ok = base::StringToUint(value, &result);
+ bool value_ok = base::StringToUint(static_cast<char*>(value), &result);
DCHECK(value_ok);
return result;
}
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698