// -> 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;
++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) {
}
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;