commit
63fb6c0d96
9
main.c
9
main.c
@ -936,10 +936,17 @@ static int load_config(char *path, struct swaylock_state *state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
swaylock_log(LOG_DEBUG, "Config Line #%d: %s", line_number, line);
|
swaylock_log(LOG_DEBUG, "Config Line #%d: %s", line_number, line);
|
||||||
char flag[nread + 3];
|
char *flag = malloc(nread + 3);
|
||||||
|
if (flag == NULL) {
|
||||||
|
free(line);
|
||||||
|
free(config);
|
||||||
|
swaylock_log(LOG_ERROR, "Failed to allocate memory");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
sprintf(flag, "--%s", line);
|
sprintf(flag, "--%s", line);
|
||||||
char *argv[] = {"swaylock", flag};
|
char *argv[] = {"swaylock", flag};
|
||||||
result = parse_options(2, argv, state, line_mode, NULL);
|
result = parse_options(2, argv, state, line_mode, NULL);
|
||||||
|
free(flag);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ add_project_arguments(
|
|||||||
'-Wno-unused-parameter',
|
'-Wno-unused-parameter',
|
||||||
'-Wno-unused-result',
|
'-Wno-unused-result',
|
||||||
'-Wundef',
|
'-Wundef',
|
||||||
|
'-Wvla',
|
||||||
],
|
],
|
||||||
language: 'c',
|
language: 'c',
|
||||||
)
|
)
|
||||||
|
20
pango.c
20
pango.c
@ -93,11 +93,15 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
|
|||||||
|
|
||||||
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
||||||
int *baseline, double scale, bool markup, const char *fmt, ...) {
|
int *baseline, double scale, bool markup, const char *fmt, ...) {
|
||||||
char buf[max_chars];
|
char *buf = malloc(max_chars);
|
||||||
|
if (buf == NULL) {
|
||||||
|
swaylock_log(LOG_ERROR, "Failed to allocate memory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
if (vsnprintf(buf, sizeof(buf), fmt, args) >= max_chars) {
|
if (vsnprintf(buf, max_chars, fmt, args) >= max_chars) {
|
||||||
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
@ -109,15 +113,21 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
|
|||||||
*baseline = pango_layout_get_baseline(layout) / PANGO_SCALE;
|
*baseline = pango_layout_get_baseline(layout) / PANGO_SCALE;
|
||||||
}
|
}
|
||||||
g_object_unref(layout);
|
g_object_unref(layout);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pango_printf(cairo_t *cairo, const char *font,
|
void pango_printf(cairo_t *cairo, const char *font,
|
||||||
double scale, bool markup, const char *fmt, ...) {
|
double scale, bool markup, const char *fmt, ...) {
|
||||||
char buf[max_chars];
|
char *buf = malloc(max_chars);
|
||||||
|
if (buf == NULL) {
|
||||||
|
swaylock_log(LOG_ERROR, "Failed to allocate memory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
if (vsnprintf(buf, sizeof(buf), fmt, args) >= max_chars) {
|
if (vsnprintf(buf, max_chars, fmt, args) >= max_chars) {
|
||||||
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
strcpy(&buf[sizeof(buf) - sizeof(overflow)], overflow);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
@ -130,4 +140,6 @@ void pango_printf(cairo_t *cairo, const char *font,
|
|||||||
pango_cairo_update_layout(cairo, layout);
|
pango_cairo_update_layout(cairo, layout);
|
||||||
pango_cairo_show_layout(cairo, layout);
|
pango_cairo_show_layout(cairo, layout);
|
||||||
g_object_unref(layout);
|
g_object_unref(layout);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user