if (meta_only && !need_parse_when_meta_only(atom_type)) {
set_position(f, get_position(f) + size - header_size);
} else if (atom_type < SUBATOMIC) {
- parse_sub_atoms(f, size - header_size, meta_only);
+ ret = parse_sub_atoms(f, size - header_size, meta_only);
+ if (ret <= 0)
+ return ret;
} else {
ret = atom_read(f, size, atom_type);
if (ret <= 0)
}
/* parse root atoms */
-static int32_t parse_atoms(struct mp4 *f, int meta_only)
+static int parse_atoms(struct mp4 *f, int meta_only)
{
int ret;
uint64_t size;
if (meta_only && !need_parse_when_meta_only(atom_type)) {
set_position(f, get_position(f) + size - header_size);
} else if (atom_type < SUBATOMIC) {
- parse_sub_atoms(f, size - header_size, meta_only);
+ ret = parse_sub_atoms(f, size - header_size, meta_only);
+ if (ret <= 0)
+ return ret;
} else {
/* skip this atom */
set_position(f, get_position(f) + size - header_size);
struct mp4 *mp4_open_read(const struct mp4_callback *cb)
{
+ int ret;
struct mp4 *f = para_calloc(sizeof(struct mp4));
f->cb = cb;
- parse_atoms(f, 0);
- if (f->error) {
+ ret = parse_atoms(f, 0);
+ if (ret < 0 || f->error) {
free(f);
- f = NULL;
+ return NULL;
}
return f;
}
struct mp4 *mp4_open_meta(const struct mp4_callback *cb)
{
+ int ret;
struct mp4 *f = para_calloc(sizeof(struct mp4));
f->cb = cb;
- parse_atoms(f, 1);
- if (f->error) {
+ ret = parse_atoms(f, 1);
+ if (ret < 0 || f->error) {
free(f);
- f = NULL;
+ return NULL;
}
return f;
}