as this seems to crash on at least some versions of MingW. Our current usage
of this function does not require it, so it should be ok to ignore.
return -1;
*cp = '\0';
cp++;
- if (strlen(cp) == 0)
- cp = NULL;
- if (!SetEnvironmentVariable(envcpy, cp))
+ if (strlen(cp))
{
- free(envcpy);
- return -1;
+ /*
+ * Only call SetEnvironmentVariable() when we are adding a variable,
+ * not when removing it. Calling it on both crashes on at least certain
+ * versions of MingW.
+ */
+ if (!SetEnvironmentVariable(envcpy, cp))
+ {
+ free(envcpy);
+ return -1;
+ }
}
free(envcpy);