mp3_afh: Let free_tag() accept NULL pointer.
[paraslash.git] / mp3_afh.c
index 484172abe6e28345073f339623f5219c390b58ce..5f73785ee39084c2ef548dc8bc36ac54ae1cd5c6 100644 (file)
--- 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;
 }
 
@@ -656,7 +657,7 @@ static int mp3_read_info(unsigned char *map, size_t numbytes, int fd,
        afhi->channels = header_channels(&header);
        afhi->seconds_total = (tv2ms(&total_time) + 500) / 1000;
        tv_divide(afhi->chunks_total, &total_time, &afhi->chunk_tv);
-       PARA_DEBUG_LOG("%lu chunks, each %lums\n", afhi->chunks_total,
+       PARA_DEBUG_LOG("%" PRIu32 "chunks, each %lums\n", afhi->chunks_total,
                tv2ms(&afhi->chunk_tv));
        ret = mp3_get_id3(map, numbytes, fd, &afhi->tags);
        afhi->techinfo = make_message("%cbr, %s, %s tags", vbr? 'v' : 'c',