From a9d791f48e3472400ffad73dca88c28fb2f7aaa7 Mon Sep 17 00:00:00 2001 From: Jesper Hansson Date: Fri, 27 Apr 2012 13:54:27 +0200 Subject: [PATCH] Plug some leaks Change-Id: I4268ea32cfb0ebd6ce5711e30865750dffa94e92 --- server/BandwidthController.cpp | 2 +- server/PppController.cpp | 5 +++++ server/TetherController.cpp | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp index e1db680..2fe249d 100644 --- a/server/BandwidthController.cpp +++ b/server/BandwidthController.cpp @@ -1100,12 +1100,12 @@ int BandwidthController::removeCostlyAlert(const char *costName, int64_t *alertB return -1; } - asprintf(&alertName, "%sAlert", costName); if (!*alertBytes) { ALOGE("No prior alert set for %s alert", costName); return -1; } + asprintf(&alertName, "%sAlert", costName); asprintf(&chainName, "bw_costly_%s", costName); asprintf(&alertQuotaCmd, ALERT_IPT_TEMPLATE, "-D", chainName, *alertBytes, alertName); res |= runIpxtablesCmd(alertQuotaCmd, IptJumpNoAdd); diff --git a/server/PppController.cpp b/server/PppController.cpp index 6b54c31..581b9c6 100644 --- a/server/PppController.cpp +++ b/server/PppController.cpp @@ -85,6 +85,8 @@ int PppController::attachPppd(const char *tty, struct in_addr local, char *lr; asprintf(&lr, "%s:%s", l, r); + free(l); + free(r); snprintf(dev, sizeof(dev), "/dev/%s", tty); @@ -94,6 +96,9 @@ int PppController::attachPppd(const char *tty, struct in_addr local, lr, "ms-dns", d1, "ms-dns", d2, "lcp-max-configure", "99999", (char *) NULL)) { ALOGE("execl failed (%s)", strerror(errno)); } + free(lr); + free(d1); + free(d2); ALOGE("Should never get here!"); return 0; } else { diff --git a/server/TetherController.cpp b/server/TetherController.cpp index fb51c06..4e1c52f 100644 --- a/server/TetherController.cpp +++ b/server/TetherController.cpp @@ -158,6 +158,8 @@ int TetherController::startTethering(int num_addrs, struct in_addr* addrs) { char *start = strdup(inet_ntoa(addrs[addrIndex++])); char *end = strdup(inet_ntoa(addrs[addrIndex++])); asprintf(&(args[nextArg++]),"--dhcp-range=%s,%s,1h", start, end); + free(start); + free(end); } if (execv(args[0], args)) { -- 2.11.0