From 5c2f3341e3c129aeb27f70fe6ca9ed0fea8f2383 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 3 Apr 2017 10:01:09 +0200 Subject: Print message to stderr when we abort due to memory demands. Closes #188. @nwellnhof - could you have a look and let me know if you think this is a bad idea or could be improved? --- src/buffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index a6754b6..629f809 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -42,7 +42,12 @@ void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size) { if (target_size < buf->asize) return; - if (target_size > (bufsize_t)(INT32_MAX / 2)) + if (target_size > (bufsize_t)(INT32_MAX / 2)) { + fprintf(stderr, + "[cmark] cmark_strbuf_grow requests buffer with size > %d, aborting\n", + (bufsize_t)(INT32_MAX / 2)); + abort(); + } abort(); /* Oversize the buffer by 50% to guarantee amortized linear time -- cgit v1.2.3