Run dialog freezes because of desktop file with %% in exec string
I analysed a problem of a freezing run dialog, Ubuntu 18.04, tried gnome-panel 3.26, (update) 3.30 and (update) 3.32. When typing in some text, a list of programs appear below. But for some programs (e.g. x11vnc 0.9.13-6), clicking on them, the dialog freezes.
I debugged the situation with debug messages and gdb. The problem appears to be the existance of double "%%" characters in the exec string of a desktop file.
E.g. x11vnc.desktop (x11vnc.desktop):
Exec=x11vnc -gui tray=setpass -rfbport PROMPT -bg -o %%HOME/.x11vnc.log.%%VNCDISPLAY
gnome-panels enters an endless loop (with high CPU usage) in function "remove_parameters":
static char *
remove_parameters (const char *exec)
{
GString *str;
char *retval, *p;
str = g_string_new (exec);
while ((p = strstr (str->str, "%"))) {
switch (p [1]) {
case '%':
g_string_erase (str, p - str->str, 1);
break;
case 'U':
case 'F':
case 'N':
case 'D':
case 'f':
case 'u':
case 'd':
case 'n':
case 'm':
case 'i':
case 'c':
case 'k':
case 'v':
g_string_erase (str, p - str->str, 2);
break;
default:
break;
}
}
retval = str->str;
g_string_free (str, FALSE);
return retval;
}
The problem is the "case '%'" - first time, p[0] = "%" and the p[1] = "%", too. Then, the first "%" will be removed + switch/case will be left with a break.
In the next iteration, the "%" with suceeding "H" is searched, but not found and we are in an endless loop.
Suggestion for a solution - maybe:
diff --git a/gnome-panel/panel-run-dialog.c b/gnome-panel/panel-run-dialog.c
index 856b27500..b6b7e999a 100644
--- a/gnome-panel/panel-run-dialog.c
+++ b/gnome-panel/panel-run-dialog.c
@@ -1031,7 +1031,7 @@ remove_parameters (const char *exec)
while ((p = strstr (str->str, "%"))) {
switch (p [1]) {
case '%':
- g_string_erase (str, p - str->str, 1);
+ g_string_erase (str, p - str->str, 2);
break;
case 'U':
case 'F':
Thanks for your help or further suggestions solving the situation!