From 16181209926798db9004f43ba9261c476a36b6bf Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 7 Mar 2016 16:11:53 +0100 Subject: [PATCH] mp3_afh: Let free_tag() accept NULL pointer. This way it is more similar to free(3) and related functions. It also allows to replace two checks in mp3_afh.c by a single check in free_tag(). --- mp3_afh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mp3_afh.c b/mp3_afh.c index 73e744ec..5f73785e 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -300,6 +300,9 @@ static int replace_tags(struct id3_tag *id3_t, struct taginfo *tags) static void free_tag(struct id3_tag *id3_t) { int i, j; + + if (!id3_t) + return; for (i = 0; i < id3_t->nframes; i++) { struct id3_frame *fr = id3_t->frames[i]; for (j = 0; j < fr->nfields; j++) { @@ -372,10 +375,8 @@ static int mp3_rewrite_tags(const char *map, size_t mapsize, ret = write_all(fd, (char *)v1_buffer, 128); } out: - if (v1_tag) - free_tag(v1_tag); - if (v2_tag) - free_tag(v2_tag); + free_tag(v1_tag); + free_tag(v2_tag); return ret; } -- 2.39.5