Skip to content

Commit

Permalink
[NaCl SDK] Fix resource leak in hello_world example.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
binji@chromium.org committed May 7, 2013
1 parent 70ce348 commit 481f580
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,22 @@ static struct PP_Var CStrToVar(const char* str) {
* Post a message back to our JavaScript
*/
static void SendMessage(PP_Instance instance, const char* str) {
if (ppb_messaging_interface)
ppb_messaging_interface->PostMessage(instance, CStrToVar(str));
if (ppb_messaging_interface) {
struct PP_Var var = CStrToVar(str);
ppb_messaging_interface->PostMessage(instance, var);
ppb_var_interface->Release(var);
}
}

/**
* Send a message to the JavaScript Console
*/
static void LogMessage(PP_Instance instance, const char* str) {
if (ppb_console_interface)
ppb_console_interface->Log(instance, PP_LOGLEVEL_ERROR, CStrToVar(str));
if (ppb_console_interface) {
struct PP_Var var = CStrToVar(str);
ppb_console_interface->Log(instance, PP_LOGLEVEL_ERROR, var);
ppb_var_interface->Release(var);
}
}

/**
Expand Down Expand Up @@ -166,7 +172,7 @@ static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,

/**
* 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] get_browser pointer to PPB_GetInterface
* @return PP_OK on success, any other value on failure.
Expand Down

0 comments on commit 481f580

Please sign in to comment.