[wiki] [sites] fix: segfault on <Ctrl-Enter> press when there is no sel || bit9tream

From: <git_AT_suckless.org>
Date: Fri, 12 Jun 2020 10:27:00 +0200

commit c05fb6ab94abc487d04cda83b533fa23fab3930b
Author: bit9tream <bit6tream_AT_cock.li>
Date: Fri Jun 12 11:26:05 2020 +0300

    fix: segfault on <Ctrl-Enter> press when there is no sel

diff --git a/tools.suckless.org/dmenu/patches/multi-selection/dmenu-multi-selection-4.9.diff b/tools.suckless.org/dmenu/patches/multi-selection/dmenu-multi-selection-4.9.diff
index 0cade666..56312e3d 100644
--- a/tools.suckless.org/dmenu/patches/multi-selection/dmenu-multi-selection-4.9.diff
+++ b/tools.suckless.org/dmenu/patches/multi-selection/dmenu-multi-selection-4.9.diff
_AT_@ -1,5 +1,5 @@
 diff --git a/dmenu.c b/dmenu.c
-index 6b8f51b..af2fc99 100644
+index 6b8f51b..b621ce3 100644
 --- a/dmenu.c
 +++ b/dmenu.c
 _AT_@ -31,7 +31,8 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
_AT_@ -55,14 +55,16 @@ index 6b8f51b..af2fc99 100644
                  drw_setscheme(drw, scheme[SchemeOut]);
          else
                  drw_setscheme(drw, scheme[SchemeNorm]);
-_AT_@ -367,6 +381,20 @@ keypress(XKeyEvent *ev)
+_AT_@ -367,6 +381,22 @@ keypress(XKeyEvent *ev)
                          goto draw;
                  case XK_Return:
                  case XK_KP_Enter:
++ if (!sel) return;
 + if (issel(sel->id)) {
 + for (int i = 0;i < selidsize;i++)
 + if (selid[i] == sel->id)
 + selid[i] = -1;
++ return;
 + } else {
 + for (int i = 0;i < selidsize;i++)
 + if (selid[i] == -1) {
_AT_@ -76,14 +78,14 @@ index 6b8f51b..af2fc99 100644
                          break;
                  case XK_bracketleft:
                          cleanup();
-_AT_@ -464,13 +492,17 @@ insert:
+_AT_@ -464,13 +494,17 @@ insert:
                  break;
          case XK_Return:
          case XK_KP_Enter:
 - puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
                  if (!(ev->state & ControlMask)) {
 + for (int i = 0;i < selidsize;i++)
-+ if (selid[i] != -1)
++ if (selid[i] != -1 && sel->id != selid[i])
 + puts(items[selid[i]].text);
 + if (sel && !(ev->state & ShiftMask))
 + puts(sel->text);
_AT_@ -97,7 +99,7 @@ index 6b8f51b..af2fc99 100644
                  break;
          case XK_Right:
                  if (text[cursor] != '-_AT_@ -534,7 +566,7 @@ readstdin(void)
+_AT_@ -534,7 +568,7 @@ readstdin(void)
                          *p = ' if (!(items[i].text = strdup(buf)))
                          die("cannot strdup %u bytes:", strlen(buf) + 1);
Received on Fri Jun 12 2020 - 10:27:00 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 12 2020 - 10:36:45 CEST