X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavdevice%2Fdshow.c;h=d7f5bd7069ac64727aea3aafd11e0d8200dabc83;hb=64ff61b3c52af335e811fe04b85108775e1f2784;hp=de910c09943440475d23e3c13f5f0b693b09324a;hpb=203bbaccfaaeac9548862e83792d38509a8c8167;p=ffmpeg diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index de910c09943..d7f5bd7069a 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -278,12 +278,12 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, goto fail1; } *device_unique_name = unique_name; + unique_name = NULL; // success, loop will end now } } else { av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name); av_log(avctx, AV_LOG_INFO, " Alternative name \"%s\"\n", unique_name); - av_free(unique_name); } fail1: @@ -291,7 +291,8 @@ fail1: IMalloc_Free(co_malloc, olestr); if (bind_ctx) IBindCtx_Release(bind_ctx); - av_free(friendly_name); + av_freep(&friendly_name); + av_freep(&unique_name); if (bag) IPropertyBag_Release(bag); IMoniker_Release(m); @@ -941,6 +942,8 @@ dshow_add_device(AVFormatContext *avctx, AVStream *st; int ret = AVERROR(EIO); + type.pbFormat = NULL; + st = avformat_new_stream(avctx, NULL); if (!st) { ret = AVERROR(ENOMEM); @@ -989,17 +992,22 @@ dshow_add_device(AVFormatContext *avctx, if (par->codec_id == AV_CODEC_ID_NONE) { av_log(avctx, AV_LOG_ERROR, "Unknown compression type. " "Please report type 0x%X.\n", (int) bih->biCompression); - return AVERROR_PATCHWELCOME; + ret = AVERROR_PATCHWELCOME; + goto error; } par->bits_per_coded_sample = bih->biBitCount; } else { par->codec_id = AV_CODEC_ID_RAWVIDEO; if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) { par->bits_per_coded_sample = bih->biBitCount; - par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); - if (par->extradata) { - par->extradata_size = 9; - memcpy(par->extradata, "BottomUp", 9); + if (par->height < 0) { + par->height *= -1; + } else { + par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); + if (par->extradata) { + par->extradata_size = 9; + memcpy(par->extradata, "BottomUp", 9); + } } } } @@ -1026,6 +1034,8 @@ dshow_add_device(AVFormatContext *avctx, ret = 0; error: + if (type.pbFormat) + CoTaskMemFree(type.pbFormat); return ret; }