diff --git a/misc.c b/misc.c index 6135b1556..63c3d4d29 100644 --- a/misc.c +++ b/misc.c @@ -2273,6 +2273,8 @@ child_set_env(char ***envp, u_int *envsizep, const char *name, * If we're passed an uninitialized list, allocate a single null * entry before continuing. */ + if ((*envp == NULL) != (*envsizep == 0)) + fatal_f("environment size mismatch"); if (*envp == NULL && *envsizep == 0) { *envp = xmalloc(sizeof(char *)); *envp[0] = NULL;