summaryrefslogtreecommitdiff
path: root/pango.c
diff options
context:
space:
mode:
authorConnor E <38229097+c-edw@users.noreply.github.com>2019-01-18 13:45:34 +0000
committerConnor E <38229097+c-edw@users.noreply.github.com>2019-01-18 13:45:34 +0000
commit7c0ba8919712a1e23eca4b4785ab9f30f9e49a7e (patch)
treed64550b7a22a786155afc2b337a42a9393da51fc /pango.c
parent291bae1e4426e698e29e31e819ebb6b2b5f02e23 (diff)
Handle alloc failures.
Diffstat (limited to 'pango.c')
-rw-r--r--pango.c8
1 files changed, 8 insertions, 0 deletions
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);