Re: [libav-devel] [PATCH] omx: Fix OOM check

2016-12-05 Thread Vittorio Giovara
On Mon, Dec 5, 2016 at 3:29 PM, Martin Storsjö  wrote:
> On Mon, 5 Dec 2016, Timothy Gu wrote:
>
>> Also use av_mallocz_array().
>>
>> Found by Coverity in FFmpeg.
>> ---
>> libavcodec/omx.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/omx.c b/libavcodec/omx.c
>> index 0c61c2f..05c8743 100644
>> --- a/libavcodec/omx.c
>> +++ b/libavcodec/omx.c
>> @@ -352,12 +352,12 @@ static av_cold int find_component(OMXContext
>> *omx_context, void *logctx,
>> av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n",
>> role);
>> return AVERROR_ENCODER_NOT_FOUND;
>> }
>> -components = av_mallocz(sizeof(char*) * num);
>> +components = av_mallocz_array(num, sizeof(*components));
>> if (!components)
>> return AVERROR(ENOMEM);
>> for (i = 0; i < num; i++) {
>> components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE);
>> -if (!components) {
>> +if (!components[i]) {
>> ret = AVERROR(ENOMEM);
>> goto end;
>> }
>> --
>> 2.10.2
>
>
> Thanks, this looks ok to me.

Timothy told me the CID for this is CID 1396839, if you are going to
push it could you please add it using our standard template (Bug-Id:
xxx)?
Thank you
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] omx: Fix OOM check

2016-12-05 Thread Martin Storsjö

On Mon, 5 Dec 2016, Timothy Gu wrote:


Also use av_mallocz_array().

Found by Coverity in FFmpeg.
---
libavcodec/omx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 0c61c2f..05c8743 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -352,12 +352,12 @@ static av_cold int find_component(OMXContext 
*omx_context, void *logctx,
av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", 
role);
return AVERROR_ENCODER_NOT_FOUND;
}
-components = av_mallocz(sizeof(char*) * num);
+components = av_mallocz_array(num, sizeof(*components));
if (!components)
return AVERROR(ENOMEM);
for (i = 0; i < num; i++) {
components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE);
-if (!components) {
+if (!components[i]) {
ret = AVERROR(ENOMEM);
goto end;
}
--
2.10.2


Thanks, this looks ok to me.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] omx: Fix OOM check

2016-12-05 Thread Timothy Gu
Also use av_mallocz_array().

Found by Coverity in FFmpeg.
---
 libavcodec/omx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 0c61c2f..05c8743 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -352,12 +352,12 @@ static av_cold int find_component(OMXContext 
*omx_context, void *logctx,
 av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", 
role);
 return AVERROR_ENCODER_NOT_FOUND;
 }
-components = av_mallocz(sizeof(char*) * num);
+components = av_mallocz_array(num, sizeof(*components));
 if (!components)
 return AVERROR(ENOMEM);
 for (i = 0; i < num; i++) {
 components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE);
-if (!components) {
+if (!components[i]) {
 ret = AVERROR(ENOMEM);
 goto end;
 }
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel