From 83c543e05165be1b0ad8acc1e81cf0a47a075fb4 Mon Sep 17 00:00:00 2001 From: Connor E <38229097+c-edw@users.noreply.github.com> Date: Sun, 20 Jan 2019 13:55:25 +0000 Subject: [PATCH] Handle malloc failure. --- common/pango.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/pango.c b/common/pango.c index 8cea5c277..7e1640432 100644 --- a/common/pango.c +++ b/common/pango.c @@ -91,6 +91,10 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, va_end(args); char *buf = malloc(length); + if (buf == NULL) { + wlr_log(WLR_ERROR, "Failed to allocate memory"); + return; + } va_start(args, fmt); vsnprintf(buf, length, fmt, args); va_end(args); @@ -114,6 +118,10 @@ void pango_printf(cairo_t *cairo, const char *font, va_end(args); char *buf = malloc(length); + if (buf == NULL) { + wlr_log(WLR_ERROR, "Failed to allocate memory"); + return; + } va_start(args, fmt); vsnprintf(buf, length, fmt, args); va_end(args);