summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-05-17 00:29:48 +0200
committerJames Almer <jamrial@gmail.com>2019-06-24 20:59:33 -0300
commit1215b3a5f3f801f1f3179b9c29a0d52f906eef98 (patch)
tree343d3868241203da0e0b1020b0d4190856820dab /libavformat
parent99147312ce6ffd3a3b70e10aacc9b64a63b6aefe (diff)
avformat/matroskadec: Don't zero unnecessarily
It is only necessary to zero the initial allocated memory used to store the size of laced frames if the block used Xiph lacing. Otherwise no unintialized data was ever used, so use av_malloc instead of av_mallocz. Also use the correct type for the allocations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/matroskadec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 09665fb680..996bddf1c1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2788,7 +2788,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
if (!type) {
*laces = 1;
- *lace_buf = av_mallocz(sizeof(int));
+ *lace_buf = av_malloc(sizeof(**lace_buf));
if (!*lace_buf)
return AVERROR(ENOMEM);
@@ -2800,7 +2800,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
*laces = *data + 1;
data += 1;
size -= 1;
- lace_size = av_mallocz(*laces * sizeof(int));
+ lace_size = av_malloc_array(*laces, sizeof(*lace_size));
if (!lace_size)
return AVERROR(ENOMEM);
@@ -2810,6 +2810,8 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
uint8_t temp;
uint32_t total = 0;
for (n = 0; res == 0 && n < *laces - 1; n++) {
+ lace_size[n] = 0;
+
while (1) {
if (size <= total) {
res = AVERROR_INVALIDDATA;