movenc: Check for allocation failures in mov_create_chapter_track

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Check that tracks->enc exists before trying to free extradata

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Properly free allocated data on failures in mov_write_header

Signed-off-by: Martin Storsjö <martin@martin.st>
movenc: Check for errors from mov_create_chapter_track

On failures in the write_trailer function, we could also ignore
the errors and try to finish the file despite these errors (which
would only leave an incomplete chapters track). It's probably better
to signal the error clearly to the caller though (and if this
function failed there's no guarantee that there's enough memory to
finish the trailer either).

Signed-off-by: Martin Storsjö <martin@martin.st>