Mercurial > libavformat.hg
comparison mov.c @ 3313:8e83e0b76105 libavformat
free moov and cmov when error occurs, fix memleak, patch by Albert Astals Cid, aastals at tv-wan dot es
author | bcoudurier |
---|---|
date | Thu, 22 May 2008 17:16:12 +0000 |
parents | 11b6da5ffe78 |
children | 0dfa207c5d69 |
comparison
equal
deleted
inserted
replaced
3312:20ea7e918398 | 3313:8e83e0b76105 |
---|---|
1563 #ifdef CONFIG_ZLIB | 1563 #ifdef CONFIG_ZLIB |
1564 ByteIOContext ctx; | 1564 ByteIOContext ctx; |
1565 uint8_t *cmov_data; | 1565 uint8_t *cmov_data; |
1566 uint8_t *moov_data; /* uncompressed data */ | 1566 uint8_t *moov_data; /* uncompressed data */ |
1567 long cmov_len, moov_len; | 1567 long cmov_len, moov_len; |
1568 int ret; | 1568 int ret = -1; |
1569 | 1569 |
1570 get_be32(pb); /* dcom atom */ | 1570 get_be32(pb); /* dcom atom */ |
1571 if (get_le32(pb) != MKTAG('d','c','o','m')) | 1571 if (get_le32(pb) != MKTAG('d','c','o','m')) |
1572 return -1; | 1572 return -1; |
1573 if (get_le32(pb) != MKTAG('z','l','i','b')) { | 1573 if (get_le32(pb) != MKTAG('z','l','i','b')) { |
1588 av_free(cmov_data); | 1588 av_free(cmov_data); |
1589 return -1; | 1589 return -1; |
1590 } | 1590 } |
1591 get_buffer(pb, cmov_data, cmov_len); | 1591 get_buffer(pb, cmov_data, cmov_len); |
1592 if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) | 1592 if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) |
1593 return -1; | 1593 goto free_and_return; |
1594 if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) | 1594 if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) |
1595 return -1; | 1595 goto free_and_return; |
1596 atom.type = MKTAG('m','o','o','v'); | 1596 atom.type = MKTAG('m','o','o','v'); |
1597 atom.offset = 0; | 1597 atom.offset = 0; |
1598 atom.size = moov_len; | 1598 atom.size = moov_len; |
1599 #ifdef DEBUG | 1599 #ifdef DEBUG |
1600 // { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); } | 1600 // { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); } |
1601 #endif | 1601 #endif |
1602 ret = mov_read_default(c, &ctx, atom); | 1602 ret = mov_read_default(c, &ctx, atom); |
1603 free_and_return: | |
1603 av_free(moov_data); | 1604 av_free(moov_data); |
1604 av_free(cmov_data); | 1605 av_free(cmov_data); |
1605 return ret; | 1606 return ret; |
1606 #else | 1607 #else |
1607 av_log(c->fc, AV_LOG_ERROR, "this file requires zlib support compiled in\n"); | 1608 av_log(c->fc, AV_LOG_ERROR, "this file requires zlib support compiled in\n"); |