X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=spx_afh.c;h=8f7d715cf20cc730d985845818c8dd49f4bde200;hp=e693c4150e03b7dae9b991c343ec7abbfe980db0;hb=761d9bd95a6601c0b3be6591a6b6672b755e1fbe;hpb=85d1f19df312c38936cf7721d67dcfb7ca034cfc diff --git a/spx_afh.c b/spx_afh.c index e693c415..8f7d715c 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Andre Noll + * Copyright (C) 2010-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -38,7 +38,6 @@ */ /** \file spx_afh.c Audio format handler for ogg/speex files. */ -#include #include #include #include @@ -57,31 +56,14 @@ struct private_spx_data { struct spx_header_info shi; }; - -static char *copy_comment(const char *src, int len) -{ - char *p = para_malloc(len + 1); - - if (len > 0) - memcpy(p, src, len); - p[len] = '\0'; - PARA_DEBUG_LOG("%s\n", p); - return p; -} - static bool copy_if_tag_type(const char *tag, int taglen, const char *type, char **p) { - int len = strlen(type); - - if (taglen <= len) - return false; - if (strncasecmp(tag, type, len)) - return false; - if (tag[len] != '=') + char *q = key_value_copy(tag, taglen, type); + if (!q) return false; free(*p); - *p = copy_comment(tag + len + 1, taglen - len - 1); + *p = q; return true; } @@ -100,7 +82,7 @@ static int spx_get_comments(unsigned char *comments, int length, c += 4; if (c + len > end) return -E_SPX_COMMENT; - tags->comment = copy_comment(c, len); + tags->comment = safe_strdup(c, len); c += len; if (c + 4 > end) @@ -129,7 +111,7 @@ static int spx_get_comments(unsigned char *comments, int length, continue; if (copy_if_tag_type(c, len, "comment", &tags->comment)) continue; - tag = copy_comment(c, len); + tag = safe_strdup(c, len); PARA_NOTICE_LOG("unrecognized comment: %s\n", tag); free(tag); }