diff options
author | wm4 <wm4@nowhere> | 2012-08-04 03:47:05 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-04 19:59:56 +0200 |
commit | 855449e67c80ba819ae8b5cfe32d59c86826a9f8 (patch) | |
tree | 4b26afe89b4cf03cffdfd797dd2311fb724266f1 /mplayer.c | |
parent | 9a2f4e10e71aa1c0c2970f807fe14000861b602b (diff) | |
download | mpv-855449e67c80ba819ae8b5cfe32d59c86826a9f8.tar.bz2 mpv-855449e67c80ba819ae8b5cfe32d59c86826a9f8.tar.xz |
mplayer: free return value of chapter_name()
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -2914,17 +2914,20 @@ int get_current_chapter(struct MPContext *mpctx) char *chapter_display_name(struct MPContext *mpctx, int chapter) { char *name = chapter_name(mpctx, chapter); + char *dname = name; if (name) { - name = talloc_asprintf(name, "(%d) %s", chapter + 1, name); + dname = talloc_asprintf(NULL, "(%d) %s", chapter + 1, name); } else { int chapter_count = get_chapter_count(mpctx); if (chapter_count <= 0) - name = talloc_asprintf(NULL, "(%d)", chapter + 1); + dname = talloc_asprintf(NULL, "(%d)", chapter + 1); else - name = talloc_asprintf(NULL, "(%d) of %d", chapter + 1, - chapter_count); + dname = talloc_asprintf(NULL, "(%d) of %d", chapter + 1, + chapter_count); } - return name; + if (dname != name) + talloc_free(name); + return dname; } // returns NULL if chapter name unavailable |