diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 21:59:36 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 21:59:36 +0000 |
commit | 481f5805b3740d7d8bae9d28dbcc8c572fbdf1f0 (patch) | |
tree | 189e63bf4145e9a1de642dfbb28046f903852875 | |
parent | 70ce3486febf363585f5b55318dc71d15f61c225 (diff) | |
download | chromium_src-481f5805b3740d7d8bae9d28dbcc8c572fbdf1f0.zip chromium_src-481f5805b3740d7d8bae9d28dbcc8c572fbdf1f0.tar.gz chromium_src-481f5805b3740d7d8bae9d28dbcc8c572fbdf1f0.tar.bz2 |
[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
-rw-r--r-- | native_client_sdk/src/examples/getting_started/hello_world/hello_world.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/native_client_sdk/src/examples/getting_started/hello_world/hello_world.c b/native_client_sdk/src/examples/getting_started/hello_world/hello_world.c index ddfc0ee..03ffa95 100644 --- a/native_client_sdk/src/examples/getting_started/hello_world/hello_world.c +++ b/native_client_sdk/src/examples/getting_started/hello_world/hello_world.c @@ -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); + } } /** @@ -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. |