diff --git a/src/ezstream.c b/src/ezstream.c index b1f550f..c0a1d94 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -297,12 +297,12 @@ processMetadata(shout_t *shout, const char *fileName) } if (!metadata_file_update(mdata)) { - metadata_free(mdata); + metadata_free(&mdata); songInfo = xstrdup(blankString); return (songInfo); } songInfo = xstrdup(metadata_get_string(mdata)); - metadata_free(mdata); + metadata_free(&mdata); if ((shout_mdata = shout_metadata_new()) == NULL) { printf("%s: shout_metadata_new(): %s\n", __progname, diff --git a/src/metadata.c b/src/metadata.c index 02816c9..baa3265 100644 --- a/src/metadata.c +++ b/src/metadata.c @@ -337,7 +337,7 @@ metadata_file(const char *filename) md = metadata_create(filename); if (!metadata_file_update(md)) { - metadata_free(md); + metadata_free(&md); return (NULL); } @@ -362,15 +362,19 @@ metadata_program(const char *program) } void -metadata_free(metadata_t *md) +metadata_free(metadata_t **md) { - if (md == NULL) + metadata_t *tmp; + + if (md == NULL || *md == NULL) return; - if (md->filename != NULL) - xfree(md->filename); - metadata_clean_md(md); - xfree(md); + tmp = *md; + + if (tmp->filename != NULL) + xfree(tmp->filename); + metadata_clean_md(tmp); + xfree(*md); } diff --git a/src/metadata.h b/src/metadata.h index 516cb39..9037f22 100644 --- a/src/metadata.h +++ b/src/metadata.h @@ -59,7 +59,7 @@ metadata_t * metadata_program(const char * /* program name */); * Free all memory used by a metadata handle that has been created with * metadata_file() or metadata_program(). */ -void metadata_free(metadata_t *); +void metadata_free(metadata_t **); /* * Update/read the metadata for the given handle. Returns 1 on success, and 0