[FFmpeg-soc] [soc]: r5313 - in concat/libavformat: avplaylist.c m3u.c pls.c utils.c.diff xspf.c
gkovacs
subversion at mplayerhq.hu
Wed Aug 26 20:41:39 CEST 2009
Author: gkovacs
Date: Wed Aug 26 20:41:39 2009
New Revision: 5313
Log:
allocate and copy string to flist rather than sharing memory with source
Modified:
concat/libavformat/avplaylist.c
concat/libavformat/m3u.c
concat/libavformat/pls.c
concat/libavformat/utils.c.diff
concat/libavformat/xspf.c
Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c Wed Aug 26 20:27:53 2009 (r5312)
+++ concat/libavformat/avplaylist.c Wed Aug 26 20:41:39 2009 (r5313)
@@ -42,7 +42,7 @@ AVPlaylistContext *av_playlist_alloc(voi
int av_playlist_insert_item(AVPlaylistContext *ctx, const char *itempath, int pos)
{
- int i;
+ int i, itempath_len;
int64_t *durations_tmp;
unsigned int *nb_streams_list_tmp;
char **flist_tmp;
@@ -56,7 +56,14 @@ int av_playlist_insert_item(AVPlaylistCo
ctx->flist = flist_tmp;
for (i = ctx->pelist_size; i > pos; --i)
ctx->flist[i] = ctx->flist[i - 1];
- ctx->flist[pos] = itempath;
+ itempath_len = strlen(itempath);
+ ctx->flist[pos] = av_malloc(itempath_len + 1);
+ if (!ctx->flist[pos]) {
+ av_log(NULL, AV_LOG_ERROR, "av_malloc error in av_playlist_insert_item\n");
+ ctx->flist[pos] = NULL;
+ return AVERROR_NOMEM;
+ }
+ av_strlcpy(ctx->flist[pos], itempath, itempath_len + 1);
ctx->flist[ctx->pelist_size] = NULL;
durations_tmp = av_realloc(ctx->durations,
sizeof(*(ctx->durations)) * (ctx->pelist_size+1));
@@ -109,6 +116,7 @@ int av_playlist_remove_item(AVPlaylistCo
char **flist_tmp;
if (pos >= ctx->pelist_size || !ctx->flist || !ctx->durations || !ctx->nb_streams_list)
return AVERROR_INVALIDDATA;
+ av_free(ctx->flist[pos]);
for (i = pos; i < ctx->pelist_size; ++i)
ctx->flist[i] = ctx->flist[i + 1];
flist_tmp = av_realloc(ctx->flist, sizeof(*(ctx->flist)) * (--ctx->pelist_size+1));
Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c Wed Aug 26 20:27:53 2009 (r5312)
+++ concat/libavformat/m3u.c Wed Aug 26 20:41:39 2009 (r5313)
@@ -98,8 +98,10 @@ static int m3u_read_header(AVFormatConte
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in m3u_read_header\n");
return AVERROR_NOMEM;
}
- for (i = 0; i < flist_len; ++i)
+ for (i = 0; i < flist_len; ++i) {
av_playlist_insert_item(ctx, flist[i], ctx->pelist_size);
+ av_free(flist[i]);
+ }
av_free(flist);
s->priv_data = ctx;
ctx->master_formatcontext = s;
Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c Wed Aug 26 20:27:53 2009 (r5312)
+++ concat/libavformat/pls.c Wed Aug 26 20:41:39 2009 (r5313)
@@ -117,8 +117,10 @@ static int pls_read_header(AVFormatConte
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in pls_read_header\n");
return AVERROR_NOMEM;
}
- for (i = 0; i < flist_len; ++i)
+ for (i = 0; i < flist_len; ++i) {
av_playlist_insert_item(ctx, flist[i], ctx->pelist_size);
+ av_free(flist[i]);
+ }
av_free(flist);
s->priv_data = ctx;
ctx->master_formatcontext = s;
Modified: concat/libavformat/utils.c.diff
==============================================================================
--- concat/libavformat/utils.c.diff Wed Aug 26 20:27:53 2009 (r5312)
+++ concat/libavformat/utils.c.diff Wed Aug 26 20:41:39 2009 (r5313)
@@ -1,5 +1,5 @@
diff --git a/libavformat/utils.c b/libavformat/utils.c
-index 4cec286..920c3fa 100644
+index 4cec286..1463428 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -27,6 +27,8 @@
@@ -21,7 +21,7 @@ index 4cec286..920c3fa 100644
AVProbeData probe_data, *pd = &probe_data;
ByteIOContext *pb = NULL;
-@@ -447,6 +450,24 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
+@@ -447,6 +450,27 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
fmt = av_probe_input_format(pd, 0);
}
@@ -32,8 +32,11 @@ index 4cec286..920c3fa 100644
+ AVPlaylistContext *playlist_ctx = ic->priv_data;
+ if (playlist_ctx) {
+ av_log(ic, AV_LOG_DEBUG, "Generating playlist from %s\n", filename);
-+ for (i = 0; i < flist_len; ++i)
++ for (i = 0; i < flist_len; ++i) {
+ av_playlist_insert_item(playlist_ctx, flist[i], playlist_ctx->pelist_size);
++ av_free(flist[i]);
++ }
++ av_free(flist);
+ av_strlcpy(ic->filename, filename, sizeof(ic->filename));
+ ff_playlist_populate_context(playlist_ctx, playlist_ctx->pe_curidx);
+ ff_playlist_set_streams(playlist_ctx);
Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c Wed Aug 26 20:27:53 2009 (r5312)
+++ concat/libavformat/xspf.c Wed Aug 26 20:41:39 2009 (r5313)
@@ -140,8 +140,10 @@ static int xspf_read_header(AVFormatCont
av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in xspf_read_header\n");
return AVERROR_NOMEM;
}
- for (i = 0; i < flist_len; ++i)
+ for (i = 0; i < flist_len; ++i) {
av_playlist_insert_item(ctx, flist[i], ctx->pelist_size);
+ av_free(flist[i]);
+ }
av_free(flist);
s->priv_data = ctx;
ctx->master_formatcontext = s;
More information about the FFmpeg-soc
mailing list