X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fscript.c;h=e465ab7be90ea352e0514f96026a5daad258e1eb;hp=81216a3ab043585b04733308442f4a7809a13440;hb=d6b45d005530496e48325a6174ecdd889a17bfc1;hpb=1fbaca31a15a37135d8d1de14c56b0df98a8ba1c diff --git a/src/script.c b/src/script.c index 81216a3a..e465ab7b 100644 --- a/src/script.c +++ b/src/script.c @@ -1,7 +1,7 @@ /* script.c -- call an external script Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2018 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ static void unputenv(const char *p) { #else // We must keep what we putenv() around in memory. // To do this without memory leaks, keep things in a list and reuse if possible. - static list_t list = {}; + static list_t list = {0}; for list_each(char, data, &list) { if(!strcmp(data, var)) { @@ -142,7 +142,12 @@ bool execute_script(const char *name, environment_t *env) { #ifdef HAVE_MINGW if(!*scriptextension) { - const char *pathext = getenv("PATHEXT") ? : ".COM;.EXE;.BAT;.CMD"; + const char *pathext = getenv("PATHEXT"); + + if(!pathext) { + pathext = ".COM;.EXE;.BAT;.CMD"; + } + size_t pathlen = strlen(pathext); size_t scriptlen = strlen(scriptname); char fullname[scriptlen + pathlen + 1];