From a15ba999d548f5e6d7537b725ea2275dc176f6f9 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 19 Oct 2021 12:39:17 +0200 Subject: [PATCH] Add a comment in the SVG exporter to explain buffer size --- caca/codec/export.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/caca/codec/export.c b/caca/codec/export.c index 2670ad7..04c8552 100644 --- a/caca/codec/export.c +++ b/caca/codec/export.c @@ -863,7 +863,13 @@ static void *export_svg(caca_canvas_t const *cv, size_t *bytes) char *data, *cur; int x, y; - /* 200 is arbitrary but should be ok */ + /* Use 200 as a safety value for character information size + * + * Worst case for background, 68 chars: + * \n + * Worst case for foreground, 97 chars: + * xxxxxx\n + */ *bytes = strlen(svg_header) + 128 + cv->width * cv->height * 200; cur = data = malloc(*bytes);