[FFmpeg-devel] [PATCH] avdevice/dshow_enummediatypes: check return of av_malloc

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Oct 31 15:46:09 CET 2015


On Wed, Oct 28, 2015 at 10:05 PM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Wed, Oct 28, 2015 at 10:00 PM, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
>> On Tue, Oct 27, 2015 at 08:09:03PM -0400, Ganesh Ajjanagadde wrote:
>>> Untested.
>>>
>>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>>> ---
>>>  libavdevice/dshow_enummediatypes.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/libavdevice/dshow_enummediatypes.c b/libavdevice/dshow_enummediatypes.c
>>> index 5b69a5b..5a24870 100644
>>> --- a/libavdevice/dshow_enummediatypes.c
>>> +++ b/libavdevice/dshow_enummediatypes.c
>>> @@ -37,6 +37,8 @@ libAVEnumMediaTypes_Next(libAVEnumMediaTypes *this, unsigned long n,
>>>      if (!this->pos && n == 1) {
>>>          if (!IsEqualGUID(&this->type.majortype, &GUID_NULL)) {
>>>              AM_MEDIA_TYPE *type = av_malloc(sizeof(AM_MEDIA_TYPE));
>>> +            if (!type)
>>> +                return AVERROR(ENOMEM);
>>
>> I cannot test this either but the surrounding code returns
>> E_POINTER, E_OUTOFMEMORY, ...
>> not AVERROR*
>> so this does not look correct, or at least inconsistent
>
> Looks like some Windows thing, I guess E_OUTOFMEMORY is the best
> choice. This needs to wait for a review from a Windows using dev IMO.

Assuming the change from AVERROR(ENOMEM) to E_OUTOFMEMORY, is this
patch ok? Worst case, build should be guaranteed.
>
>>
>> [...]
>> --
>> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> Freedom in capitalist society always remains about the same as it was in
>> ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>


More information about the ffmpeg-devel mailing list