X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fid3v1.c;h=218ed73f81ec522071422fe5dd1f8c07bc430a35;hb=7eef45a76f82d0760a895f1970145b0d6c95abf2;hp=0617a9cf82a5b3ed65345cab5b53f858a3ccc63d;hpb=7ca10d10aae32fa42b6afc486328a7ec017bd457;p=ffmpeg diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c index 0617a9cf82a..218ed73f81e 100644 --- a/libavformat/id3v1.c +++ b/libavformat/id3v1.c @@ -179,7 +179,7 @@ static void get_string(AVFormatContext *s, const char *key, const uint8_t *buf, int buf_size) { int i, c; - char *q, str[512]; + char *q, str[512], *first_free_space = NULL; q = str; for(i = 0; i < buf_size; i++) { @@ -188,10 +188,19 @@ static void get_string(AVFormatContext *s, const char *key, break; if ((q - str) >= sizeof(str) - 1) break; + if (c == ' ') { + if (!first_free_space) + first_free_space = q; + } else { + first_free_space = NULL; + } *q++ = c; } *q = '\0'; + if (first_free_space) + *first_free_space = '\0'; + if (*str) av_dict_set(&s->metadata, key, str, 0); }