summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSungguk Na <sungguk.na@samsung.com>2017-09-29 10:09:24 +0900
committerSungguk Na <sungguk.na@samsung.com>2017-09-29 10:11:33 +0900
commit73b06d6d8ea880594b9175d2b96f95e7a4bd42a3 (patch)
treea1f458d2ea83198e6e6522d2dcec8c939acee5fa
parenta27e395a3ec92ebbd7e88c4b03f822f7d89d53fe (diff)
downloadmemps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.tar.gz
memps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.tar.bz2
memps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.zip
22581 Checked_return 36976 Resource_leak Change-Id: I983248d1a48d8029f4a8cca2d2eb0997af0410de Signed-off-by: Sungguk Na <sungguk.na@samsung.com>
-rw-r--r--memps.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/memps.c b/memps.c
index 524f51d..8a7e9af 100644
--- a/memps.c
+++ b/memps.c
@@ -649,14 +649,15 @@ static int get_tmpfs_info(FILE *output_fp)
while (fgets(line, BUF_MAX, fp) != NULL) {
if (sscanf(line, "tmpfs %ms tmpfs", &tmpfs_mp) == 1) {
- statfs(tmpfs_mp, &tmpfs_info);
- fprintf(output_fp,
- "tmpfs %16s Total %8ld KB, Used %8ld, Avail %8ld\n",
- tmpfs_mp,
- /* 1 block is 4 KB */
- tmpfs_info.f_blocks * 4,
- (tmpfs_info.f_blocks - tmpfs_info.f_bfree) * 4,
- tmpfs_info.f_bfree * 4);
+ if (statfs(tmpfs_mp, &tmpfs_info) == 0) {
+ fprintf(output_fp,
+ "tmpfs %16s Total %8ld KB, Used %8ld, Avail %8ld\n",
+ tmpfs_mp,
+ /* 1 block is 4 KB */
+ tmpfs_info.f_blocks * 4,
+ (tmpfs_info.f_blocks - tmpfs_info.f_bfree) * 4,
+ tmpfs_info.f_bfree * 4);
+ }
free(tmpfs_mp);
}
}
@@ -1162,6 +1163,7 @@ static int show_map_new(int pid)
{
mapinfo *milist;
mapinfo *mi;
+ mapinfo *temp = NULL;
unsigned shared_dirty = 0;
unsigned shared_clean = 0;
unsigned private_dirty = 0;
@@ -1192,7 +1194,7 @@ static int show_map_new(int pid)
printf("-------- -------- -------------------"
"------------------\n");
}
- for (mi = milist; mi; mi = mi->next) {
+ for (mi = milist; mi;) {
shared_clean += mi->shared_clean;
shared_dirty += mi->shared_dirty;
private_clean += mi->private_clean;
@@ -1210,6 +1212,13 @@ static int show_map_new(int pid)
if ((mi->next && !strcmp(mi->next->name, mi->name)) &&
(mi->next->start == mi->end)) {
duplication = 1;
+
+ temp = mi;
+ mi = mi->next;
+ free(temp->perm);
+ free(temp->name);
+ free(temp);
+ temp = NULL;
continue;
}
end = mi->end;
@@ -1224,6 +1233,13 @@ static int show_map_new(int pid)
shared_dirty = 0;
private_clean = 0;
private_dirty = 0;
+
+ temp = mi;
+ mi = mi->next;
+ free(temp->perm);
+ free(temp->name);
+ free(temp);
+ temp = NULL;
}
if (sum) {
printf("%8d %8d %8d %8d %18d\n",