From 7c0ba8919712a1e23eca4b4785ab9f30f9e49a7e Mon Sep 17 00:00:00 2001 From: Connor E <38229097+c-edw@users.noreply.github.com> Date: Fri, 18 Jan 2019 13:45:34 +0000 Subject: Handle alloc failures. --- pango.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pango.c') diff --git a/pango.c b/pango.c index f40750b..8e80015 100644 --- a/pango.c +++ b/pango.c @@ -94,6 +94,10 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, int *baseline, double scale, bool markup, const char *fmt, ...) { char *buf = malloc(max_chars); + if (buf == NULL) { + swaylock_log(LOG_ERROR, "Failed to allocate memory"); + return; + } va_list args; va_start(args, fmt); @@ -116,6 +120,10 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, void pango_printf(cairo_t *cairo, const char *font, double scale, bool markup, const char *fmt, ...) { char *buf = malloc(max_chars); + if (buf == NULL) { + swaylock_log(LOG_ERROR, "Failed to allocate memory"); + return; + } va_list args; va_start(args, fmt); -- cgit v1.2.3