omx: Fix OOM check

Also use av_mallocz_array().

Fixes CID1396839.
pull/242/head
Timothy Gu 8 years ago
parent 581f93f37e
commit 16a75304fe
  1. 4
      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); av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role);
return AVERROR_ENCODER_NOT_FOUND; return AVERROR_ENCODER_NOT_FOUND;
} }
components = av_mallocz(sizeof(char*) * num); components = av_mallocz_array(num, sizeof(*components));
if (!components) if (!components)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE); components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE);
if (!components) { if (!components[i]) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto end; goto end;
} }

Loading…
Cancel
Save