Skip to content

Commit

Permalink
Merge pull request #83 from hbeni/fixMemleaks
Browse files Browse the repository at this point in the history
Fix #81 memleaks
  • Loading branch information
hbeni authored Feb 17, 2021
2 parents 98831ec + 3daa24d commit f8acbfa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 2 additions & 4 deletions client/mumble-plugin/fgcom-mumble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ void fgcom_updateClientComment() {
const char *comment;
if (mumAPI.getUserComment(ownPluginID, activeConnection, localMumId, &comment) == STATUS_OK) {
std::string comment_str(comment);
mumAPI.freeMemory(ownPluginID, &comment);
std::smatch sm;
std::regex re("^([\\w\\W]*)<p name=\"FGCOM\">.*"); // cool trick: . does not match newline, but \w with negated \W matches really everything
//pluginDbg("fgcom_updateClientComment(): got previous comment: '"+comment_str+"'");
Expand All @@ -221,7 +220,8 @@ void fgcom_updateClientComment() {
preservedComment = comment_str;
}
}

mumAPI.freeMemory(ownPluginID, comment);

// Add FGCom generic infos
newComment += "<b>FGCom</b> (v"+std::to_string(FGCOM_VERSION_MAJOR)+"."+std::to_string(FGCOM_VERSION_MINOR)+"."+std::to_string(FGCOM_VERSION_PATCH)+"): ";
newComment += (fgcom_isPluginActive())? "active" : "inactive";
Expand Down Expand Up @@ -424,7 +424,6 @@ mumble_error_t fgcom_initPlugin() {
}
fgcom_remotecfg_mtx.unlock();
pluginLog("got local clientID="+std::to_string(localUser));
mumAPI.freeMemory(ownPluginID, &localUser);
}


Expand Down Expand Up @@ -483,7 +482,6 @@ mumble_error_t fgcom_initPlugin() {
pluginLog("Error fetching current active channel: rc="+std::to_string(glcres));
return EC_CHANNEL_NOT_FOUND; // abort online init - something horribly went wrong.
}
mumAPI.freeMemory(ownPluginID, &localChannelID);

if (!fgcom_isPluginActive()) fgcom_setPluginActive(fgcom_isPluginActive()); // print some nice message to start

Expand Down
3 changes: 0 additions & 3 deletions client/mumble-plugin/lib/io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,11 @@ void notifyRemotes(int iid, FGCOM_NOTIFY_T what, int selector, mumble_userid_t t
mumble_channelid_t localChannelID;
if (mumAPI.getChannelOfUser(ownPluginID, activeConnection, localMumId, &localChannelID) != STATUS_OK) {
pluginLog("[ERROR]: Can't obtain channel of local user");
mumAPI.freeMemory(ownPluginID, &localChannelID);
return;
}

if (mumAPI.getUsersInChannel(ownPluginID, activeConnection, localChannelID, &userIDs, &userCount) != STATUS_OK) {
pluginLog("[ERROR]: Can't obtain user list");
mumAPI.freeMemory(ownPluginID, &localChannelID);
return;
} else {
pluginDbg("There are "+std::to_string(userCount)+" users on this channel.");
Expand Down Expand Up @@ -308,7 +306,6 @@ void notifyRemotes(int iid, FGCOM_NOTIFY_T what, int selector, mumble_userid_t t

}

mumAPI.freeMemory(ownPluginID, &localChannelID);
mumAPI.freeMemory(ownPluginID, userIDs);
pluginDbg(" notification for dataID='"+dataID+"' done.");
}
Expand Down

0 comments on commit f8acbfa

Please sign in to comment.