xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 5970a10e8db657ddd2e5338368cd2c4b26b37ba5

Handle one more edge case
When there are no environment variables at all.

Found by clang-checker.
Author: xaizek
Author date (UTC): 2012-10-18 15:00
Committer name: xaizek
Committer date (UTC): 2012-10-18 15:00
Parent(s): 418204dba0e9d47b51103c856b853034cbd97c79
Signing key:
Tree: 66a369aa4c3a7e2f634a65806ff72d64fcac451e
File Lines added Lines deleted
src/engine/variables.c 18 13
File src/engine/variables.c changed (mode: 100644) (index dd1df0392..fdf46237e)
... ... static size_t nvars;
62 62 void void
63 63 init_variables(void) init_variables(void)
64 64 { {
65 int i;
65 int env_count;
66 66 extern char **environ; extern char **environ;
67 67
68 68 if(nvars > 0) if(nvars > 0)
69 69 clear_variables(); clear_variables();
70 70
71 71 /* count environment variables */ /* count environment variables */
72 i = 0;
73 while(environ[i] != NULL)
74 i++;
75
76 /* allocate memory for environment variables */
77 vars = malloc(sizeof(*vars)*i);
78 assert(vars != NULL);
72 env_count = 0;
73 while(environ[env_count] != NULL)
74 env_count++;
79 75
80 /* initialize variable list */
81 i = 0;
82 while(environ[i] != NULL)
76 if(env_count > 0)
83 77 { {
84 init_var(environ[i]);
85 i++;
78 int i;
79
80 /* allocate memory for environment variables */
81 vars = malloc(sizeof(*vars)*env_count);
82 assert(vars != NULL);
83
84 /* initialize variable list */
85 i = 0;
86 while(environ[i] != NULL)
87 {
88 init_var(environ[i]);
89 i++;
90 }
86 91 } }
87 92
88 93 init_parser(&local_getenv); init_parser(&local_getenv);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master