Message ID | 20200521023647.27847-1-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 1fd8528c4ece70ac031c8c210610e1e8b25508a4 |
Headers | show |
Series | [FFmpeg-devel,1/3] avformat/matroskadec: Beautify matroska_parse_laces() | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavformat/matroskadec.c | 27 +++++++++++---------------- > 1 file changed, 11 insertions(+), 16 deletions(-) > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 4fa32365c3..c02c2561c1 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -3035,9 +3035,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, > if (size <= 0) > return AVERROR_INVALIDDATA; > > - *laces = *data + 1; > - data += 1; > - size -= 1; > + *laces = *data + 1; > + data += 1; > + size -= 1; > > switch (type) { > case 0x1: /* Xiph lacing */ > @@ -3047,31 +3047,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, > for (n = 0; n < *laces - 1; n++) { > lace_size[n] = 0; > > - while (1) { > - if (size <= total) { > + do { > + if (size <= total) > return AVERROR_INVALIDDATA; > - } > temp = *data; > total += temp; > lace_size[n] += temp; > data += 1; > size -= 1; > - if (temp != 0xff) > - break; > - } > + } while (temp == 0xff); > } > - if (size < total) { > + if (size < total) > return AVERROR_INVALIDDATA; > - } > > lace_size[n] = size - total; > break; > } > > case 0x2: /* fixed-size lacing */ > - if (size % (*laces)) { > + if (size % (*laces)) > return AVERROR_INVALIDDATA; > - } > for (n = 0; n < *laces; n++) > lace_size[n] = size / *laces; > break; > @@ -3107,15 +3102,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, > } > data += offset; > size -= offset; > - if (size < total) { > + if (size < total) > return AVERROR_INVALIDDATA; > - } > + > lace_size[*laces - 1] = size - total; > break; > } > } > > - *buf = data; > + *buf = data; > > return 0; > } > Will apply the rest of this patchset tomorrow if there are no objections. - Andreas
Andreas Rheinhardt: > Andreas Rheinhardt: >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> >> --- >> libavformat/matroskadec.c | 27 +++++++++++---------------- >> 1 file changed, 11 insertions(+), 16 deletions(-) >> >> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c >> index 4fa32365c3..c02c2561c1 100644 >> --- a/libavformat/matroskadec.c >> +++ b/libavformat/matroskadec.c >> @@ -3035,9 +3035,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, >> if (size <= 0) >> return AVERROR_INVALIDDATA; >> >> - *laces = *data + 1; >> - data += 1; >> - size -= 1; >> + *laces = *data + 1; >> + data += 1; >> + size -= 1; >> >> switch (type) { >> case 0x1: /* Xiph lacing */ >> @@ -3047,31 +3047,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, >> for (n = 0; n < *laces - 1; n++) { >> lace_size[n] = 0; >> >> - while (1) { >> - if (size <= total) { >> + do { >> + if (size <= total) >> return AVERROR_INVALIDDATA; >> - } >> temp = *data; >> total += temp; >> lace_size[n] += temp; >> data += 1; >> size -= 1; >> - if (temp != 0xff) >> - break; >> - } >> + } while (temp == 0xff); >> } >> - if (size < total) { >> + if (size < total) >> return AVERROR_INVALIDDATA; >> - } >> >> lace_size[n] = size - total; >> break; >> } >> >> case 0x2: /* fixed-size lacing */ >> - if (size % (*laces)) { >> + if (size % (*laces)) >> return AVERROR_INVALIDDATA; >> - } >> for (n = 0; n < *laces; n++) >> lace_size[n] = size / *laces; >> break; >> @@ -3107,15 +3102,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, >> } >> data += offset; >> size -= offset; >> - if (size < total) { >> + if (size < total) >> return AVERROR_INVALIDDATA; >> - } >> + >> lace_size[*laces - 1] = size - total; >> break; >> } >> } >> >> - *buf = data; >> + *buf = data; >> >> return 0; >> } >> > Will apply the rest of this patchset tomorrow if there are no objections. > > - Andreas > Applied. - Andreas
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4fa32365c3..c02c2561c1 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3035,9 +3035,9 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, if (size <= 0) return AVERROR_INVALIDDATA; - *laces = *data + 1; - data += 1; - size -= 1; + *laces = *data + 1; + data += 1; + size -= 1; switch (type) { case 0x1: /* Xiph lacing */ @@ -3047,31 +3047,26 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, for (n = 0; n < *laces - 1; n++) { lace_size[n] = 0; - while (1) { - if (size <= total) { + do { + if (size <= total) return AVERROR_INVALIDDATA; - } temp = *data; total += temp; lace_size[n] += temp; data += 1; size -= 1; - if (temp != 0xff) - break; - } + } while (temp == 0xff); } - if (size < total) { + if (size < total) return AVERROR_INVALIDDATA; - } lace_size[n] = size - total; break; } case 0x2: /* fixed-size lacing */ - if (size % (*laces)) { + if (size % (*laces)) return AVERROR_INVALIDDATA; - } for (n = 0; n < *laces; n++) lace_size[n] = size / *laces; break; @@ -3107,15 +3102,15 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, } data += offset; size -= offset; - if (size < total) { + if (size < total) return AVERROR_INVALIDDATA; - } + lace_size[*laces - 1] = size - total; break; } } - *buf = data; + *buf = data; return 0; }
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/matroskadec.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)