diff --git a/java/webclient/src_moz/PreferencesImpl.cpp b/java/webclient/src_moz/PreferencesImpl.cpp index 6818052c1eb9..e905d2a3171a 100644 --- a/java/webclient/src_moz/PreferencesImpl.cpp +++ b/java/webclient/src_moz/PreferencesImpl.cpp @@ -300,7 +300,13 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeRegisterPr prefs = wcContext->sPrefs; PR_ASSERT(prefs); - // step one, set up our struct + // step one: create a const char * from the prefName + if (nsnull == (prefNameChars = ::util_GetStringUTFChars(env, prefName))) { + ::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get string for prefName"); + return; + } + + // step two, set up our struct peStruct *pes = new peStruct(); pes->cx = wcContext; @@ -308,12 +314,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_PreferencesImpl_nativeRegisterPr pes->callback = ::util_NewGlobalRef(env, callback); closures.Put(nsDependentCString(prefNameChars), pes); - // step two: create a const char * from the prefName - if (nsnull == (prefNameChars = ::util_GetStringUTFChars(env, prefName))) { - ::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get string for prefName"); - return; - } - rv = prefs->RegisterCallback(prefNameChars, prefChanged, pes); if (NS_FAILED(rv)) {