diff options
author | Adam Domurad <[email protected]> | 2012-06-15 15:27:12 -0400 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2012-06-15 15:27:12 -0400 |
commit | 8ca285c865a27687cbc84525e8331aeb1b923389 (patch) | |
tree | 1bd8c5e8401661380619ef684212b4ff8023f688 /plugin/icedteanp | |
parent | 51b3c90f20ed3c29866cd40ce057365a4ac17954 (diff) |
Fixed two memory leaks in C++ side of plugin
Diffstat (limited to 'plugin/icedteanp')
-rw-r--r-- | plugin/icedteanp/IcedTeaNPPlugin.cc | 3 | ||||
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginUtils.cc | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc index f3d30a4..24189d6 100644 --- a/plugin/icedteanp/IcedTeaNPPlugin.cc +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc @@ -1303,11 +1303,14 @@ void consume_message(gchar* message) { g_free(cookie_info); cookie_info = NULL; } + g_strfreev (parts); + parts = NULL; } else { g_print (" Unable to handle message: %s\n", message); } + } void get_instance_from_id(int id, NPP& instance) diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc index d5bed13..c57277c 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.cc +++ b/plugin/icedteanp/IcedTeaPluginUtils.cc @@ -1124,27 +1124,23 @@ MessageBus::unSubscribe(BusSubscriber* b) void MessageBus::post(const char* message) { - char* msg = (char*) malloc(sizeof(char)*strlen(message) + 1); bool message_consumed = false; - // consumer frees this memory - strcpy(msg, message); - PLUGIN_DEBUG("Trying to lock %p...\n", &msg_queue_mutex); pthread_mutex_lock(&subscriber_mutex); - PLUGIN_DEBUG("Message %s received on bus. Notifying subscribers.\n", msg); + PLUGIN_DEBUG("Message %s received on bus. Notifying subscribers.\n", message); std::list<BusSubscriber*>::const_iterator i; for( i = subscribers.begin(); i != subscribers.end() && !message_consumed; ++i ) { - PLUGIN_DEBUG("Notifying subscriber %p of %s\n", *i, msg); - message_consumed = ((BusSubscriber*) *i)->newMessageOnBus(msg); + PLUGIN_DEBUG("Notifying subscriber %p of %s\n", *i, message); + message_consumed = ((BusSubscriber*) *i)->newMessageOnBus(message); } pthread_mutex_unlock(&subscriber_mutex); if (!message_consumed) - PLUGIN_DEBUG("Warning: No consumer found for message %s\n", msg); + PLUGIN_DEBUG("Warning: No consumer found for message %s\n", message); PLUGIN_DEBUG("%p unlocked...\n", &msg_queue_mutex); } |