diff options
author | Sungguk Na <sungguk.na@samsung.com> | 2017-09-29 10:09:24 +0900 |
---|---|---|
committer | Sungguk Na <sungguk.na@samsung.com> | 2017-09-29 10:11:33 +0900 |
commit | 73b06d6d8ea880594b9175d2b96f95e7a4bd42a3 (patch) | |
tree | a1f458d2ea83198e6e6522d2dcec8c939acee5fa | |
parent | a27e395a3ec92ebbd7e88c4b03f822f7d89d53fe (diff) | |
download | memps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.tar.gz memps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.tar.bz2 memps-73b06d6d8ea880594b9175d2b96f95e7a4bd42a3.zip |
Fix Coverity issuestizen_4.0.m2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_5.0/20181101.000004submit/tizen_4.0/20171010.054207submit/tizen/20171019.073616submit/tizen/20171011.011352accepted/tizen/unified/20171019.145735accepted/tizen/5.0/unified/20181102.021012accepted/tizen/4.0/unified/20171011.071204tizen_5.0accepted/tizen_5.0_unified
22581 Checked_return
36976 Resource_leak
Change-Id: I983248d1a48d8029f4a8cca2d2eb0997af0410de
Signed-off-by: Sungguk Na <sungguk.na@samsung.com>
-rw-r--r-- | memps.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -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", |