omx: Fix allocation check

Also use av_mallocz_array().

Bug-Id: CID 1396839
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
This commit is contained in:
Timothy Gu 2016-12-05 09:29:12 -08:00 committed by Vittorio Giovara
parent d32bdadda8
commit d3da8a0035
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}