aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-30 21:52:59 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-09-30 22:19:54 +0200
commit610efb67739f850d7d08779f55661e15bc6f6722 (patch)
treeb51b1eae154462ffce602aa31004cd986a4add58 /tools
parentf4d9148fe282879b9fcc755767c9c04de9ddbcfa (diff)
downloadffmpeg-610efb67739f850d7d08779f55661e15bc6f6722.tar.gz
qt-faststart: dont allocate a bigger buffer than needed
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'tools')
-rw-r--r--tools/qt-faststart.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c
index bfa6f1a489..b1917f18ef 100644
--- a/tools/qt-faststart.c
+++ b/tools/qt-faststart.c
@@ -37,6 +37,8 @@
#define ftello(x) _ftelli64(x)
#endif
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
@@ -293,9 +295,10 @@ int main(int argc, char *argv[])
}
/* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
- copy_buffer = malloc(COPY_BUFFER_SIZE);
+ bytes_to_copy = FFMIN(COPY_BUFFER_SIZE, last_offset);
+ copy_buffer = malloc(bytes_to_copy);
if (!copy_buffer) {
- printf("could not allocate %"PRIu64" bytes for copy_buffer\n", COPY_BUFFER_SIZE);
+ printf("could not allocate %"PRIu64" bytes for copy_buffer\n", bytes_to_copy);
goto error_out;
}
printf(" copying rest of file...\n");