X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=fftools%2Fffmpeg_hw.c;h=962d8f7d5a4fb21e4b717738fad4e1641e43c66e;hb=1108bd517363c50740025fcc58ae1e572c8150a0;hp=2ec181385430b260c662b53ea97275a80aa7c59f;hpb=398000abcf980d239a789da6f69811913d2fc635;p=ffmpeg diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 2ec18138543..962d8f7d5a4 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -99,7 +99,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out) // -> av_hwdevice_ctx_create_derived() AVDictionary *options = NULL; - char *type_name = NULL, *name = NULL, *device = NULL; + const char *type_name = NULL, *name = NULL, *device = NULL; enum AVHWDeviceType type; HWDevice *dev, *src; AVBufferRef *device_ref = NULL; @@ -155,10 +155,12 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out) ++p; q = strchr(p, ','); if (q) { - device = av_strndup(p, q - p); - if (!device) { - err = AVERROR(ENOMEM); - goto fail; + if (q - p > 0) { + device = av_strndup(p, q - p); + if (!device) { + err = AVERROR(ENOMEM); + goto fail; + } } err = av_dict_parse_string(&options, q + 1, "=", ",", 0); if (err < 0) { @@ -168,7 +170,8 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out) } err = av_hwdevice_ctx_create(&device_ref, type, - device ? device : p, options, 0); + q ? device : p[0] ? p : NULL, + options, 0); if (err < 0) goto fail;