mirror of
https://github.com/swaywm/sway.git
synced 2026-04-28 06:46:26 -04:00
Handle malloc failure.
This commit is contained in:
parent
445d948734
commit
83c543e051
1 changed files with 8 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue