File: handle-unavailable-environment-variables.patch

package info (click to toggle)
gmrun 0.9.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 736 kB
  • ctags: 682
  • sloc: cpp: 1,922; sh: 439; makefile: 39; ansic: 9
file content (44 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Description: handle unavailable environment variables
 fix gmrun crash when the enivornment variables HOME and PATH are not available
Author: Lukas Schwaighofer <lukas@schwaighofer.name>
Bug-Debian: https://bugs.debian.org/715974

--- a/src/gtkcompletionline.cc
+++ b/src/gtkcompletionline.cc
@@ -328,7 +328,9 @@
 static void
 generate_path()
 {
-  char *path_cstr = (char*)getenv("PATH");
+  const char *path_cstr = (char*)getenv("PATH");
+  if (path_cstr == NULL)
+    path_cstr = "";
 
   istringstream path_ss(path_cstr);
   string tmp;
--- a/src/prefs.cc
+++ b/src/prefs.cc
@@ -35,13 +35,16 @@
   file_name += GMRUNRC;
   init(file_name);
 
-  file_name = getenv("HOME");
-  if (!file_name.empty()) {
-    string::iterator i = file_name.end() - 1;
-    if (*i == '/') file_name.erase(i);
-    file_name += "/.";
-    file_name += GMRUNRC;
-    init(file_name);
+  const char *home_cstr = getenv("HOME");
+  if (home_cstr != NULL) {
+    file_name = home_cstr;
+    if (!file_name.empty()) {
+      string::iterator i = file_name.end() - 1;
+      if (*i == '/') file_name.erase(i);
+      file_name += "/.";
+      file_name += GMRUNRC;
+      init(file_name);
+    }
   }
 }