if (!mxf->aesc && s->key && s->keylen == 16) {
mxf->aesc = av_malloc(av_aes_size);
+ if (!mxf->aesc)
+ return -1;
av_aes_init(mxf->aesc, s->key, 128, 1);
}
// crypto context
static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
{
mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
+ if (!mxf->metadata_sets)
+ return -1;
mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
mxf->metadata_sets_count++;
return 0;
if (mxf->packages_count >= UINT_MAX / sizeof(UID))
return -1;
mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
+ if (!mxf->packages_refs)
+ return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ if (!package->tracks_refs)
+ return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
return -1;
sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
+ if (!sequence->structural_components_refs)
+ return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
break;
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ if (!package->tracks_refs)
+ return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
+ if (!descriptor->sub_descriptors_refs)
+ return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
break;
case 0x8201: /* Private tag used by SONY C0023S01.mxf */
descriptor->extradata = av_malloc(size);
+ if (!descriptor->extradata)
+ return -1;
descriptor->extradata_size = size;
get_buffer(pb, descriptor->extradata, size);
break;
MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
uint64_t klv_end= url_ftell(pb) + klv->length;
+ if (!ctx)
+ return -1;
while (url_ftell(pb) + 4 < klv_end) {
int tag = get_be16(pb);
int size = get_be16(pb); /* KLV specified by 0x53 */