List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/2] ui-stats: free without condition
@ 2015-10-12  8:59 list
  2015-10-12  8:59 ` [PATCH 2/2] ui-stats: do not duplicate string list
  2015-10-12  9:10 ` [PATCH 1/2] ui-stats: free without condition john
  0 siblings, 2 replies; 7+ messages in thread
From: list @ 2015-10-12  8:59 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

xstrdup() returns allocated memory or NULL. It's safe to call free()
without condition.

Coverity-Id 13839 is kind of false posivtive, but this should fix it
nevertheless.

Coverity-Id: 13839
Signed-off-by: Christian Hesse <mail at eworm.de>
---
 ui-stats.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ui-stats.c b/ui-stats.c
index 74ce0f7..02335e7 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -180,8 +180,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 	author = string_list_insert(authors, tmp);
 	if (!author->util)
 		author->util = xcalloc(1, sizeof(struct authorstat));
-	else
-		free(tmp);
+	free(tmp);
 	authorstat = author->util;
 	items = &authorstat->list;
 	t = info->committer_date;
@@ -189,8 +188,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 	period->trunc(date);
 	tmp = xstrdup(period->pretty(date));
 	item = string_list_insert(items, tmp);
-	if (item->util)
-		free(tmp);
+	free(tmp);
 	item->util++;
 	authorstat->total++;
 	cgit_free_commitinfo(info);
-- 
2.6.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-12 20:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12  8:59 [PATCH 1/2] ui-stats: free without condition list
2015-10-12  8:59 ` [PATCH 2/2] ui-stats: do not duplicate string list
2015-10-12  9:11   ` john
2015-10-12  9:10 ` [PATCH 1/2] ui-stats: free without condition john
2015-10-12  9:14   ` list
2015-10-12 18:29     ` list
2015-10-12 20:29       ` john

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).