From 08b7b3c68ddad8c6ad95eb01db4be376fefcd1d7 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 2 Dec 2010 15:10:50 +0000 Subject: [PATCH] Fix crash when syncing autofill settings. Since we moved the autofill initiation code out of the constructor and into it's own method, we may crash if there is an autofill profile set but the feature is turned off (i.e. the user had it on at one point and had a profile set up but turned it off without deleting the profile). That's because in this case we execute setAutoFillProfile() in WebSettings without having first called the new init method. It makes sense to not sync any profiles though when the feature is not enabled, so add that check. Change-Id: I9d99e96347770e5b08c982513f2370cb770cbe94 --- WebKit/android/jni/WebSettings.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 6b40b65b0..75f42b39c 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -514,15 +514,17 @@ public: if (!oldAutoFillSetting && flag) webAutoFill->searchDocument(pFrame); - // Set the active AutoFillProfile data. - jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); - if (autoFillProfile) - syncAutoFillProfile(env, autoFillProfile, webAutoFill); - else { - // The autofill profile is null. We need to tell Chromium about this because - // this may be because the user just deleted their profile but left the - // autofill feature setting enabled. - webAutoFill->clearProfiles(); + if (flag) { + // Set the active AutoFillProfile data. + jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); + if (autoFillProfile) + syncAutoFillProfile(env, autoFillProfile, webAutoFill); + else { + // The autofill profile is null. We need to tell Chromium about this because + // this may be because the user just deleted their profile but left the + // autofill feature setting enabled. + webAutoFill->clearProfiles(); + } } #endif } -- 2.11.0