diff options
author | wm4 <nfxjfg@googlemail.com> | 2015-01-05 18:56:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-01-05 20:52:51 +0100 |
commit | bd7801040786788433bcb80b713aeb30e0de1ce0 (patch) | |
tree | 8e4de6721e9d28d8f2df9e480866ba5840c6dfa6 /libavformat/id3v1.c | |
parent | 08810a8895174231b8cf6eb58c6c2aec4c6db778 (diff) | |
download | ffmpeg-bd7801040786788433bcb80b713aeb30e0de1ce0.tar.gz |
avformat/id3v1: strip trailing whitespace
ID3v1 fields have a fixed size, and they are padded either with zeros,
or with spaces. Handle the latter case, instead of putting strings with
trailing spaces into the AVDictionary.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/id3v1.c')
-rw-r--r-- | libavformat/id3v1.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c index 0617a9cf82..218ed73f81 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); } |