Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1254)

Unified Diff: native_client_sdk/src/examples/getting_started/hello_world/hello_world.c

Issue 14779007: [NaCl SDK] Fix resource leak in hello_world example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/getting_started/hello_world/hello_world.c
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 ddfc0eefd2f90520f8d6eabee80d35c1518b6879..03ffa957f549b76f33537b89504d8557dfabf106 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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698