diff options
author | Deepak Bhole <[email protected]> | 2011-03-03 17:09:54 -0500 |
---|---|---|
committer | Deepak Bhole <[email protected]> | 2011-03-03 17:09:54 -0500 |
commit | 42b3fd0a3fcfa1fc5113f7c23215a600ee408ea8 (patch) | |
tree | 5c2c49f42bab714879c5c7ea6f6e9919e4bc9408 /plugin | |
parent | 98fe68de729d68ed362bf24e8b318343a22b1aa8 (diff) |
Added check for instance validity before making calls to the browser
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginRequestProcessor.cc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc index 1e49515..b34372a 100644 --- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc +++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc @@ -221,6 +221,10 @@ PluginRequestProcessor::eval(std::vector<std::string*>* message_parts) window_ptr = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(message_parts->at(5)); instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(window_ptr); + // If instance is invalid, do not proceed further + if (!instance) + return; + java_result = request_processor.getString(*(message_parts->at(6))); CHECK_JAVA_RESULT(java_result); script.append(*(java_result->return_string)); @@ -280,6 +284,10 @@ PluginRequestProcessor::call(std::vector<std::string*>* message_parts) std::string response = std::string(); JavaRequestProcessor java_request = JavaRequestProcessor(); JavaResultData* java_result; + NPVariant* result_variant; + std::string result_variant_jniid = std::string(); + NPVariant* args_array; + AsyncCallThreadData thread_data = AsyncCallThreadData(); reference = atoi(message_parts->at(3)->c_str()); @@ -290,6 +298,10 @@ PluginRequestProcessor::call(std::vector<std::string*>* message_parts) // instance instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(window_ptr); + // If instance is invalid, do not proceed further + if (!instance) + goto cleanup; + // function name java_result = java_request.getString(*(message_parts->at(6))); CHECK_JAVA_RESULT(java_result); @@ -314,11 +326,10 @@ PluginRequestProcessor::call(std::vector<std::string*>* message_parts) } arg_count = args.size(); - NPVariant *args_array = (NPVariant*) malloc(sizeof(NPVariant)*args.size()); + args_array = (NPVariant*) malloc(sizeof(NPVariant)*args.size()); for (int i=0; i < args.size(); i++) args_array[i] = args[i]; - AsyncCallThreadData thread_data = AsyncCallThreadData(); thread_data.result_ready = false; thread_data.parameters = std::vector<void*>(); thread_data.result = std::string(); @@ -344,8 +355,7 @@ PluginRequestProcessor::call(std::vector<std::string*>* message_parts) } #endif - NPVariant* result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result); - std::string result_variant_jniid = std::string(); + result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result); if (result_variant) { @@ -390,6 +400,11 @@ PluginRequestProcessor::sendString(std::vector<std::string*>* message_parts) thread_data.result = std::string(); NPP instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(variant); + + // If instance is invalid, do not proceed further + if (!instance) + return; + thread_data.parameters.push_back(instance); thread_data.parameters.push_back(variant); @@ -455,6 +470,10 @@ PluginRequestProcessor::setMember(std::vector<std::string*>* message_parts) instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(member); + // If instance is invalid, do not proceed further + if (!instance) + return; + if (*(message_parts->at(4)) == "SetSlot") { property_identifier = browser_functions.getintidentifier(atoi(message_parts->at(6)->c_str())); @@ -569,6 +588,11 @@ PluginRequestProcessor::sendMember(std::vector<std::string*>* message_parts) thread_data.result = std::string(); NPP instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(parent_ptr); + + // If instance is invalid, do not proceed further + if (!instance) + return; + thread_data.parameters.push_back(instance); thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*parent_ptr)); thread_data.parameters.push_back(&member_identifier); |