diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-06-08 10:48:23 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-06-08 10:48:23 +0000 |
commit | 23b20b5cf34e2c78ddc5c7a52ca787402eab9d52 (patch) | |
tree | 89a9a8375427c81ba29a71d14b84209a33ea113a | |
parent | 59c2959d07d7019350b10661b02ba17e6d0c4fa5 (diff) | |
download | ffmpeg-streaming-23b20b5cf34e2c78ddc5c7a52ca787402eab9d52.zip ffmpeg-streaming-23b20b5cf34e2c78ddc5c7a52ca787402eab9d52.tar.gz |
Search /usr(/local)/share for preset files as well.
This also fixed a null pointer dereference if HOME isnt set.
Originally committed as revision 13708 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | ffmpeg.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -3638,19 +3638,25 @@ static int opt_bsf(const char *opt, const char *arg) static int opt_preset(const char *opt, const char *arg) { - FILE *f; + FILE *f=NULL; char tmp[100], tmp2[100]; - char *home= getenv("HOME"); + int i; + const char *base[3]= { getenv("HOME"), + "/usr/local/share", + "/usr/share", + }; - snprintf(tmp, sizeof(tmp), "%s/.ffmpeg/%s.ffpreset", home, arg); + for(i=!base[0]; i<3 && !f; i++){ + snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg); f= fopen(tmp, "r"); if(!f){ char *codec_name= *opt == 'v' ? video_codec_name : *opt == 'a' ? audio_codec_name : subtitle_codec_name; - snprintf(tmp, sizeof(tmp), "%s/.ffmpeg/%s-%s.ffpreset", home, codec_name, arg); + snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s-%s.ffpreset", base[i], i ? "" : ".", codec_name, arg); f= fopen(tmp, "r"); } + } if(!f){ fprintf(stderr, "Preset file not found\n"); |