From aeefba219094355e76a185fdcfc4852523b3b9e0 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 14 Mar 2011 11:37:56 +1100 Subject: [PATCH] Allocate slightly more so we can cope when the buffer overflows and fall back to a real temporary file. --- lrzip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lrzip.c b/lrzip.c index 0d7f87a..f388aee 100644 --- a/lrzip.c +++ b/lrzip.c @@ -348,8 +348,10 @@ void read_tmpinfile(rzip_control *control, int fd_in) static void open_tmpoutbuf(rzip_control *control) { control->flags |= FLAG_TMP_OUTBUF; - control->out_maxlen = control->maxram + control->page_size; - control->tmp_outbuf = malloc(control->out_maxlen); + control->out_maxlen = control->maxram; + /* Allocate slightly more so we can cope when the buffer overflows and + * fall back to a real temporary file */ + control->tmp_outbuf = malloc(control->out_maxlen + control->page_size); if (unlikely(!control->tmp_outbuf)) fatal("Failed to malloc tmp_outbuf in open_tmpoutbuf\n"); if (!DECOMPRESS && !TEST_ONLY)