My patch was incomplete -- str was still accessed later, after the
debug printf, so a better fix was due.

Mikhail sent my diff upstream[0], where was improved and committed[1]
a couple of hours ago.  Here's an adaptation for the version we have
currently in tree.

[0]: https://github.com/davatorium/rofi/pull/1902
[1]: 
https://github.com/davatorium/rofi/commit/a6d297591ef4d389a3d0043afb887b0bdb48a317

(sneaking in a plist update too while here)

ok?

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/sysutils/rofi/Makefile,v
retrieving revision 1.41
diff -u -p -r1.41 Makefile
--- Makefile    27 Sep 2023 17:16:33 -0000      1.41
+++ Makefile    30 Sep 2023 08:53:55 -0000
@@ -2,7 +2,7 @@ COMMENT =               window switcher, run dialog a
 
 V =                    1.7.5
 DISTNAME =             rofi-${V}
-REVISION =             0
+REVISION =             1
 
 CATEGORIES =           sysutils x11
 HOMEPAGE =             https://github.com/davatorium/rofi
@@ -35,6 +35,8 @@ CONFIGURE_STYLE =     gnu
 CONFIGURE_ARGS =       --disable-check
 CONFIGURE_ENV =                CPPFLAGS="-I${LOCALBASE}/include 
-I${X11BASE}/include" \
                        YACC="bison -y"
+
+DEBUG_PACKAGES =       ${BUILD_PACKAGES}
 
 pre-configure:
        sed -i 's,/usr/bin/env bash,/bin/sh,' ${WRKSRC}/script/get_git_rev.sh
Index: patches/patch-source_xcb_c
===================================================================
RCS file: patches/patch-source_xcb_c
diff -N patches/patch-source_xcb_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_xcb_c  30 Sep 2023 15:06:23 -0000
@@ -0,0 +1,25 @@
+adaptation of https://github.com/davatorium/rofi/commit/a6d297591e
+
+Index: source/xcb.c
+--- source/xcb.c.orig
++++ source/xcb.c
+@@ -1475,13 +1475,16 @@ static void x11_helper_discover_window_manager(void) {
+         xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win);
+     if (xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) 
{
+       if (wtitle.strings_len > 0) {
+-        g_debug("Found window manager: |%s|", wtitle.strings);
+-        if (g_strcmp0(wtitle.strings, "i3") == 0) {
++        // Copy the string and add terminating '\0'.
++        char *str = g_strndup(wtitle.strings, wtitle.strings_len);
++        g_debug("Found window manager: |%s|", str);
++        if (g_strcmp0(str, "i3") == 0) {
+           current_window_manager =
+               WM_DO_NOT_CHANGE_CURRENT_DESKTOP | WM_PANGO_WORKSPACE_NAMES;
+-        } else if (g_strcmp0(wtitle.strings, "bspwm") == 0) {
++        } else if (g_strcmp0(str, "bspwm") == 0) {
+           current_window_manager = WM_ROOT_WINDOW_OFFSET;
+         }
++        g_free(str);
+       }
+       xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle);
+     }
Index: pkg/PLIST
===================================================================
RCS file: /home/cvs/ports/sysutils/rofi/pkg/PLIST,v
retrieving revision 1.15
diff -u -p -r1.15 PLIST
--- pkg/PLIST   21 Aug 2022 18:55:20 -0000      1.15
+++ pkg/PLIST   30 Sep 2023 15:11:41 -0000
@@ -16,7 +16,6 @@ lib/pkgconfig/rofi.pc
 @man man/man5/rofi-keys.5
 @man man/man5/rofi-script.5
 @man man/man5/rofi-theme.5
-share/applications/
 share/applications/rofi-theme-selector.desktop
 share/applications/rofi.desktop
 share/examples/rofi/
@@ -24,8 +23,6 @@ share/examples/rofi/i3_empty_workspace.s
 share/examples/rofi/i3_switch_workspaces.sh
 share/examples/rofi/rofi-file-browser.sh
 share/examples/rofi/test_script_mode.sh
-share/icons/
-share/icons/hicolor/
 share/icons/hicolor/apps/
 share/icons/hicolor/apps/rofi.svg
 share/rofi/

Reply via email to