Re: [FFmpeg-devel] [PATCH] ffplay: dynamically allocate filename buffer
On Sat, Sep 26, 2015 at 4:50 PM, Timo Rothenpielerwrote: >> @@ -3120,7 +3121,10 @@ static VideoState *stream_open(const char *filename, >> AVInputFormat *iformat) >> is = av_mallocz(sizeof(VideoState)); >> if (!is) >> return NULL; >> -av_strlcpy(is->filename, filename, sizeof(is->filename)); >> +is->filename = av_malloc(strlen(filename)+1); >> +if (!is->filename) >> +goto fail; >> +strcpy(is->filename, filename); > > av_strdup thanks, updated patch. > >> is->iformat = iformat; >> is->ytop= 0; >> is->xleft = 0; > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffplay: dynamically allocate filename buffer
> @@ -3120,7 +3121,10 @@ static VideoState *stream_open(const char *filename, > AVInputFormat *iformat) > is = av_mallocz(sizeof(VideoState)); > if (!is) > return NULL; > -av_strlcpy(is->filename, filename, sizeof(is->filename)); > +is->filename = av_malloc(strlen(filename)+1); > +if (!is->filename) > +goto fail; > +strcpy(is->filename, filename); av_strdup > is->iformat = iformat; > is->ytop= 0; > is->xleft = 0; signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] 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--- ffplay.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index fb4af24..55435bc 100644 --- a/ffplay.c +++ b/ffplay.c @@ -290,7 +290,7 @@ typedef struct VideoState { SDL_Rect last_display_rect; int eof; -char filename[1024]; +char *filename; int width, height, xleft, ytop; int step; @@ -1137,6 +1137,7 @@ static void stream_close(VideoState *is) sws_freeContext(is->img_convert_ctx); #endif sws_freeContext(is->sub_convert_ctx); +av_free(is->filename); av_free(is); } @@ -3120,7 +3121,10 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat) is = av_mallocz(sizeof(VideoState)); if (!is) return NULL; -av_strlcpy(is->filename, filename, sizeof(is->filename)); +is->filename = av_malloc(strlen(filename)+1); +if (!is->filename) +goto fail; +strcpy(is->filename, filename); is->iformat = iformat; is->ytop= 0; is->xleft = 0; -- 2.5.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel