aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-02-07 21:24:16 +0100
committerGitHub <noreply@github.com>2021-02-07 21:24:16 +0100
commitfd6eaa17660732c98a000cb92399d04f003654a6 (patch)
tree371fbb954541041ab970e33a72e4e7f0a03da3de /src
parent37352aa7e19e0bfebbd0c32985cbf79a83508538 (diff)
parentd0e34c85f85510cb2ef591de29693b4cf8bdc65b (diff)
Merge pull request #4525 from sternenseemann/lowdown-0.8.0
libcmd/markdown: handle allocation errors in lowdown_term_rndr
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/markdown.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc
index 40788a42f..d25113d93 100644
--- a/src/libcmd/markdown.cc
+++ b/src/libcmd/markdown.cc
@@ -3,9 +3,7 @@
#include "finally.hh"
#include <sys/queue.h>
-extern "C" {
#include <lowdown.h>
-}
namespace nix {
@@ -42,7 +40,9 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
throw Error("cannot allocate Markdown output buffer");
Finally freeBuffer([&]() { lowdown_buf_free(buf); });
- lowdown_term_rndr(buf, nullptr, renderer, node);
+ int rndr_res = lowdown_term_rndr(buf, nullptr, renderer, node);
+ if (!rndr_res)
+ throw Error("allocation error while rendering Markdown");
return std::string(buf->data, buf->size);
}