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

gkovacs subversion at mplayerhq.hu
Tue Aug 25 08:56:31 CEST 2009


Author: gkovacs
Date: Tue Aug 25 08:56:31 2009
New Revision: 5259

Log:
return AVERROR_NOMEM upon allocation failure in av_playlist_split_encodedstring

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

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c	Tue Aug 25 08:30:43 2009	(r5258)
+++ concat/libavformat/avplaylist.c	Tue Aug 25 08:56:31 2009	(r5259)
@@ -139,21 +139,27 @@ AVFormatContext *av_playlist_formatconte
     return ic;
 }
 
-void av_playlist_split_encodedstring(const char *s,
+int av_playlist_split_encodedstring(const char *s,
                                      const char sep,
                                      char ***flist_ptr,
                                      int *len_ptr)
 {
     char c, *ts, **flist;
-    int i, len, buflen, *sepidx;
+    int i, len, buflen, *sepidx, *sepidx_tmp;
     sepidx = NULL;
     buflen = len = 0;
-    sepidx = av_fast_realloc(sepidx, &buflen, ++len);
+    sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
+    if (!sepidx_tmp) {
+        av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_split_encodedstring\n");
+        av_free(sepidx);
+        return AVERROR_NOMEM;
+    }
+    else
+        sepidx = sepidx_tmp;
     sepidx[0] = 0;
     ts = s;
     while ((c = *ts++) != 0) {
         if (c == sep) {
-            int *sepidx_tmp;
             sepidx[len] = ts-s;
             sepidx_tmp = av_fast_realloc(sepidx, &buflen, ++len);
             if (!sepidx_tmp) {
@@ -161,7 +167,7 @@ void av_playlist_split_encodedstring(con
                 av_log(NULL, AV_LOG_ERROR, "av_fast_realloc error in av_playlist_split_encodedstring\n");
                 *flist_ptr = NULL;
                 *len_ptr = 0;
-                return;
+                return AVERROR_NOMEM;
             } else
                 sepidx = sepidx_tmp;
         }
@@ -177,7 +183,7 @@ void av_playlist_split_encodedstring(con
             av_log(NULL, AV_LOG_ERROR, "av_malloc error in av_playlist_split_encodedstring\n");
             *flist_ptr = NULL;
             *len_ptr = 0;
-            return;
+            return AVERROR_NOMEM;
         }
         av_strlcpy(flist[i], ts+sepidx[i], sepidx[i+1]-sepidx[i]);
     }

Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h	Tue Aug 25 08:30:43 2009	(r5258)
+++ concat/libavformat/avplaylist.h	Tue Aug 25 08:56:31 2009	(r5259)
@@ -94,8 +94,9 @@ void av_playlist_relative_paths(char **f
  *  @param sep The delimiter character (',').
  *  @param flist_ptr Pointer to string list which will be allocated by function.
  *  @param len_ptr Number of segments the string was split into.
+ *  @return Returns 0 upon success, or negative upon failure.
  */
-void av_playlist_split_encodedstring(const char *s,
+int av_playlist_split_encodedstring(const char *s,
                                      const char sep,
                                      char ***flist_ptr,
                                      int *len_ptr);


More information about the FFmpeg-soc mailing list