Browse code

ffplay: dynamically allocate filename buffer

filename was set to an arbitrary 1024 characters. ffplay would thus be unable to
play files whose name exceeds that arbitrary threshold.

This patch dynamically allocates and frees the filename buffer to remove such
limitations.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>

Ganesh Ajjanagadde authored on 2015/09/27 06:09:52
Showing 1 changed files
... ...
@@ -285,7 +285,7 @@ typedef struct VideoState {
285 285
     SDL_Rect last_display_rect;
286 286
     int eof;
287 287
 
288
-    char filename[1024];
288
+    char *filename;
289 289
     int width, height, xleft, ytop;
290 290
     int step;
291 291
 
... ...
@@ -1132,6 +1132,7 @@ static void stream_close(VideoState *is)
1132 1132
     sws_freeContext(is->img_convert_ctx);
1133 1133
 #endif
1134 1134
     sws_freeContext(is->sub_convert_ctx);
1135
+    av_free(is->filename);
1135 1136
     av_free(is);
1136 1137
 }
1137 1138
 
... ...
@@ -3099,7 +3100,9 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
3099 3099
     is = av_mallocz(sizeof(VideoState));
3100 3100
     if (!is)
3101 3101
         return NULL;
3102
-    av_strlcpy(is->filename, filename, sizeof(is->filename));
3102
+    is->filename = av_strdup(filename);
3103
+    if (!is->filename)
3104
+        goto fail;
3103 3105
     is->iformat = iformat;
3104 3106
     is->ytop    = 0;
3105 3107
     is->xleft   = 0;