diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-16 17:21:14 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-22 03:58:18 +0100 |
commit | 05ae0b239fbad170f98099cdb4e44d064b776059 (patch) | |
tree | e7df6b03989938f9ab1caf4f912ac75712a47362 /libavformat/matroskadec.c | |
parent | 7471f473c587fe4acb07bdc5c7800ae2f361fc30 (diff) | |
download | ffmpeg-05ae0b239fbad170f98099cdb4e44d064b776059.tar.gz |
avformat/matroskadec: Beautify setting default values
Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r-- | libavformat/matroskadec.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8f7ab64ba5..23e2286adb 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1114,28 +1114,29 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, int res; if (data) { - for (int i = 0; syntax[i].id; i++) + for (int i = 0; syntax[i].id; i++) { + void *dst = (char *)data + syntax[i].data_offset; switch (syntax[i].type) { case EBML_UINT: - *(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u; + *(uint64_t *)dst = syntax[i].def.u; break; case EBML_SINT: - *(int64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.i; + *(int64_t *) dst = syntax[i].def.i; break; case EBML_FLOAT: - *(double *) ((char *) data + syntax[i].data_offset) = syntax[i].def.f; + *(double *) dst = syntax[i].def.f; break; case EBML_STR: case EBML_UTF8: // the default may be NULL if (syntax[i].def.s) { - uint8_t **dst = (uint8_t **) ((uint8_t *) data + syntax[i].data_offset); - *dst = av_strdup(syntax[i].def.s); - if (!*dst) + *(char**)dst = av_strdup(syntax[i].def.s); + if (!*(char**)dst) return AVERROR(ENOMEM); } break; } + } if (!matroska->levels[matroska->num_levels - 1].length) { matroska->num_levels--; |