~adnano/wmenu-devel

Fix crash when some line contains % v1 APPLIED

Nikita Ivanov: 1
 Fix crash when some line contains %

 2 files changed, 7 insertions(+), 7 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~adnano/wmenu-devel/patches/41647/mbox | git am -3
Learn more about email & git

[PATCH] Fix crash when some line contains % Export this patch

---
Should be fixed now.

I've noticed that all the functions that were fixed do not take
advantage of printf format string (they all use "%s"). It means that
wmenu does a lot of useless job by parsing a format string. Maybe we
should simplify the functions to just accept a string?
Thank you for explaining how this thing works, this is new to me because
I had never contributed to a project via a mail list before.
 main.c  | 12 ++++++------
 pango.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/main.c b/main.c
index 33f29a1..3e857ac 100644
--- a/main.c
+++ b/main.c
@@ -110,7 +110,7 @@ int render_text(struct menu_state *state, cairo_t *cairo, const char *str,
		int left_padding, int right_padding) {

	int text_width, text_height;
	get_text_size(cairo, state->font, &text_width, &text_height, NULL, 1, str);
	get_text_size(cairo, state->font, &text_width, &text_height, NULL, 1, "%s", str);
	int text_y = (state->line_height / 2.0) - (text_height / 2.0);

	if (background) {
@@ -122,7 +122,7 @@ int render_text(struct menu_state *state, cairo_t *cairo, const char *str,

	cairo_move_to(cairo, x + left_padding, y + text_y);
	cairo_set_source_u32(cairo, foreground);
	pango_printf(cairo, state->font, 1, str);
	pango_printf(cairo, state->font, 1, "%s", str);

	return x + text_width + left_padding + right_padding;
}
@@ -133,7 +133,7 @@ int render_horizontal_item(struct menu_state *state, cairo_t *cairo, const char
		int left_padding, int right_padding) {

	int text_width, text_height;
	get_text_size(cairo, state->font, &text_width, &text_height, NULL, 1, str);
	get_text_size(cairo, state->font, &text_width, &text_height, NULL, 1, "%s", str);
	int text_y = (state->line_height / 2.0) - (text_height / 2.0);

	if (x + left_padding + text_width > width) {
@@ -148,7 +148,7 @@ int render_horizontal_item(struct menu_state *state, cairo_t *cairo, const char

		cairo_move_to(cairo, x + left_padding, y + text_y);
		cairo_set_source_u32(cairo, foreground);
		pango_printf(cairo, state->font, 1, str);
		pango_printf(cairo, state->font, 1, "%s", str);
	}

	return x + text_width + left_padding + right_padding;
@@ -160,7 +160,7 @@ void render_vertical_item(struct menu_state *state, cairo_t *cairo, const char *
		int left_padding) {

	int text_height;
	get_text_size(cairo, state->font, NULL, &text_height, NULL, 1, str);
	get_text_size(cairo, state->font, NULL, &text_height, NULL, 1, "%s", str);
	int text_y = (state->line_height / 2.0) - (text_height / 2.0);

	if (background) {
@@ -172,7 +172,7 @@ void render_vertical_item(struct menu_state *state, cairo_t *cairo, const char *

	cairo_move_to(cairo, x + left_padding, y + text_y);
	cairo_set_source_u32(cairo, foreground);
	pango_printf(cairo, state->font, 1, str);
	pango_printf(cairo, state->font, 1, "%s", str);
}

void scroll_matches(struct menu_state *state) {
diff --git a/pango.c b/pango.c
index ac5ff4e..22c1487 100644
--- a/pango.c
+++ b/pango.c
@@ -66,7 +66,7 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,

int text_width(cairo_t *cairo, const char *font, const char *text) {
	int text_width;
	get_text_size(cairo, font, &text_width, NULL, NULL, 1, text);
	get_text_size(cairo, font, &text_width, NULL, NULL, 1, "%s", text);
	return text_width;
}

-- 
2.41.0
Thanks!

To git@git.sr.ht:~adnano/wmenu
   8b1724c..9ee9da3  master -> master