From: Johannes W. <ja...@mo...> - 2011-03-24 16:36:02
|
--- cache.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cache.c b/cache.c index 6b9e6b8..1408e48 100644 --- a/cache.c +++ b/cache.c @@ -114,7 +114,7 @@ static struct track_info *cache_entry_to_ti(struct cache_entry *e) // NOTE: filename already copied by track_info_new() pos = strlen(strings) + 1; - ti->codec = xstrdup(strings + pos); + ti->codec = strings[pos] ? xstrdup(strings + pos) : NULL; pos += strlen(strings + pos) + 1; kv = xnew(struct keyval, count + 1); for (i = 0; i < count; i++) { @@ -297,7 +297,7 @@ static void write_ti(int fd, struct gbuf *buf, struct track_info *ti, unsigned i e.mtime = ti->mtime; len[count] = strlen(ti->filename) + 1; e.size += len[count++]; - len[count] = strlen(ti->codec) + 1; + len[count] = (ti->codec ? strlen(ti->codec) : 0) + 1; e.size += len[count++]; for (i = 0; kv[i].key; i++) { len[count] = strlen(kv[i].key) + 1; @@ -315,7 +315,7 @@ static void write_ti(int fd, struct gbuf *buf, struct track_info *ti, unsigned i gbuf_set(buf, 0, pad); gbuf_add_bytes(buf, &e, sizeof(e)); gbuf_add_bytes(buf, ti->filename, len[count++]); - gbuf_add_bytes(buf, ti->codec, len[count++]); + gbuf_add_bytes(buf, ti->codec ? ti->codec : "", len[count++]); for (i = 0; kv[i].key; i++) { gbuf_add_bytes(buf, kv[i].key, len[count++]); gbuf_add_bytes(buf, kv[i].val, len[count++]); -- 1.7.4.1 |