Commit 481f5805 authored by binji@chromium.org's avatar binji@chromium.org

[NaCl SDK] Fix resource leak in hello_world example.

BUG=176596
R=noelallen@chromium.org

Review URL: https://codereview.chromium.org/14779007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198808 0039d316-1c4b-4281-b951-d872f2087c98
parent 70ce3486
...@@ -57,16 +57,22 @@ static struct PP_Var CStrToVar(const char* str) { ...@@ -57,16 +57,22 @@ static struct PP_Var CStrToVar(const char* str) {
* Post a message back to our JavaScript * Post a message back to our JavaScript
*/ */
static void SendMessage(PP_Instance instance, const char* str) { static void SendMessage(PP_Instance instance, const char* str) {
if (ppb_messaging_interface) if (ppb_messaging_interface) {
ppb_messaging_interface->PostMessage(instance, CStrToVar(str)); struct PP_Var var = CStrToVar(str);
ppb_messaging_interface->PostMessage(instance, var);
ppb_var_interface->Release(var);
}
} }
/** /**
* Send a message to the JavaScript Console * Send a message to the JavaScript Console
*/ */
static void LogMessage(PP_Instance instance, const char* str) { static void LogMessage(PP_Instance instance, const char* str) {
if (ppb_console_interface) if (ppb_console_interface) {
ppb_console_interface->Log(instance, PP_LOGLEVEL_ERROR, CStrToVar(str)); struct PP_Var var = CStrToVar(str);
ppb_console_interface->Log(instance, PP_LOGLEVEL_ERROR, var);
ppb_var_interface->Release(var);
}
} }
/** /**
...@@ -166,7 +172,7 @@ static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, ...@@ -166,7 +172,7 @@ static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,
/** /**
* Entry points for the module. * Entry points for the module.
* Initialize needed interfaces: PPB_Core, PPB_Messaging and PPB_Var. * Initialize needed interfaces: PPB_Console, PPB_Messaging and PPB_Var.
* @param[in] a_module_id module ID * @param[in] a_module_id module ID
* @param[in] get_browser pointer to PPB_GetInterface * @param[in] get_browser pointer to PPB_GetInterface
* @return PP_OK on success, any other value on failure. * @return PP_OK on success, any other value on failure.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment