[FFmpeg-soc] [soc]: r5242 - in concat/libavformat: avplaylist.c avplaylist.h

gkovacs subversion at mplayerhq.hu
Mon Aug 24 08:35:31 CEST 2009


Author: gkovacs
Date: Mon Aug 24 08:35:31 2009
New Revision: 5242

Log:
error checking in av_playlist_populate_context

Modified:
   concat/libavformat/avplaylist.c
   concat/libavformat/avplaylist.h

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c	Mon Aug 24 08:24:15 2009	(r5241)
+++ concat/libavformat/avplaylist.c	Mon Aug 24 08:35:31 2009	(r5242)
@@ -57,12 +57,20 @@ AVFormatContext *av_playlist_alloc_forma
     return ic;
 }
 
-void av_playlist_populate_context(AVPlaylistContext *ctx, int pe_curidx)
+int av_playlist_populate_context(AVPlaylistContext *ctx, int pe_curidx)
 {
-    ctx->formatcontext_list = av_realloc(ctx->formatcontext_list, sizeof(*(ctx->formatcontext_list)) * (pe_curidx+2));
+    AVFormatContext **formatcontext_list_tmp = av_realloc(ctx->formatcontext_list, sizeof(*(ctx->formatcontext_list)) * (pe_curidx+2));
+    if (!formatcontext_list_tmp) {
+        av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_populate_context\n");
+        av_free(ctx->formatcontext_list);
+        return AVERROR_NOMEM;
+    }
+    ctx->formatcontext_list = formatcontext_list_tmp;
     ctx->formatcontext_list[pe_curidx+1] = NULL;
-    ctx->formatcontext_list[pe_curidx] = av_playlist_alloc_formatcontext(ctx->flist[pe_curidx]);
+    if (!(ctx->formatcontext_list[pe_curidx] = av_playlist_alloc_formatcontext(ctx->flist[pe_curidx])))
+        return AVERROR_NOFMT;
     ctx->nb_streams_list[pe_curidx] = ctx->formatcontext_list[pe_curidx]->nb_streams;
+    return 0;
 }
 
 void av_playlist_set_streams(AVFormatContext *s)

Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h	Mon Aug 24 08:24:15 2009	(r5241)
+++ concat/libavformat/avplaylist.h	Mon Aug 24 08:35:31 2009	(r5242)
@@ -57,8 +57,9 @@ AVFormatContext *av_playlist_alloc_forma
 /** @brief Opens the playlist element with the specified index from the AVPlaylistContext.
  *  @param ctx AVPlaylistContext containing the desired playlist element.
  *  @param pe_curidx Index of the playlist element to be opened.
+ *  @return Returns 0 upon success, or negative upon failure.
  */
-void av_playlist_populate_context(AVPlaylistContext *ctx, int pe_curidx);
+int av_playlist_populate_context(AVPlaylistContext *ctx, int pe_curidx);
 
 /** @brief Sets the master concat-type demuxer's streams to those of its currently opened playlist element.
  *  @param s AVFormatContext of the concat-type demuxer, which contains the AVPlaylistContext and substreams.


More information about the FFmpeg-soc mailing list