process: fix unitialized variables (#1719)
* process: fix potential unitialized variables * process: fix brace initializer error on Windows
This commit is contained in:
parent
14260166fc
commit
566da99680
|
@ -36,6 +36,7 @@ typedef wchar_t *process_env_t;
|
||||||
|
|
||||||
#define HANDLE_INVALID (INVALID_HANDLE_VALUE)
|
#define HANDLE_INVALID (INVALID_HANDLE_VALUE)
|
||||||
#define PROCESS_GET_HANDLE(P) ((P)->process_information.hProcess)
|
#define PROCESS_GET_HANDLE(P) ((P)->process_information.hProcess)
|
||||||
|
#define PROCESS_ARGLIST_INITIALIZER { 0 }
|
||||||
|
|
||||||
static volatile long PipeSerialNumber;
|
static volatile long PipeSerialNumber;
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ typedef char **process_env_t;
|
||||||
|
|
||||||
#define HANDLE_INVALID (0)
|
#define HANDLE_INVALID (0)
|
||||||
#define PROCESS_GET_HANDLE(P) ((P)->pid)
|
#define PROCESS_GET_HANDLE(P) ((P)->pid)
|
||||||
|
#define PROCESS_ARGLIST_INITIALIZER NULL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -437,6 +439,7 @@ static int process_arglist_add(process_arglist_t *list, size_t *list_len, const
|
||||||
|
|
||||||
|
|
||||||
static void process_arglist_free(process_arglist_t *list) {
|
static void process_arglist_free(process_arglist_t *list) {
|
||||||
|
if (!*list) return;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
char **cmd = *list;
|
char **cmd = *list;
|
||||||
for (int i = 0; cmd[i]; i++)
|
for (int i = 0; cmd[i]; i++)
|
||||||
|
@ -574,7 +577,8 @@ static void process_env_free(process_env_t *list, size_t list_len) {
|
||||||
static int process_start(lua_State* L) {
|
static int process_start(lua_State* L) {
|
||||||
int r, retval = 1;
|
int r, retval = 1;
|
||||||
size_t env_len = 0, cmd_len = 0, arglist_len = 0, env_vars_len = 0;
|
size_t env_len = 0, cmd_len = 0, arglist_len = 0, env_vars_len = 0;
|
||||||
process_arglist_t arglist;
|
process_t *self = NULL;
|
||||||
|
process_arglist_t arglist = PROCESS_ARGLIST_INITIALIZER;
|
||||||
process_env_t env_vars = NULL;
|
process_env_t env_vars = NULL;
|
||||||
const char *cwd = NULL;
|
const char *cwd = NULL;
|
||||||
bool detach = false, escape = true;
|
bool detach = false, escape = true;
|
||||||
|
@ -664,7 +668,7 @@ static int process_start(lua_State* L) {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
process_t* self = lua_newuserdata(L, sizeof(process_t));
|
self = lua_newuserdata(L, sizeof(process_t));
|
||||||
memset(self, 0, sizeof(process_t));
|
memset(self, 0, sizeof(process_t));
|
||||||
luaL_setmetatable(L, API_TYPE_PROCESS);
|
luaL_setmetatable(L, API_TYPE_PROCESS);
|
||||||
self->deadline = deadline;
|
self->deadline = deadline;
|
||||||
|
@ -822,10 +826,12 @@ static int process_start(lua_State* L) {
|
||||||
if (control_pipe[0]) close(control_pipe[0]);
|
if (control_pipe[0]) close(control_pipe[0]);
|
||||||
if (control_pipe[1]) close(control_pipe[1]);
|
if (control_pipe[1]) close(control_pipe[1]);
|
||||||
#endif
|
#endif
|
||||||
for (int stream = 0; stream < 3; ++stream) {
|
if (self) {
|
||||||
process_stream_t* pipe = &self->child_pipes[stream][stream == STDIN_FD ? 0 : 1];
|
for (int stream = 0; stream < 3; ++stream) {
|
||||||
if (*pipe) {
|
process_stream_t* pipe = &self->child_pipes[stream][stream == STDIN_FD ? 0 : 1];
|
||||||
close_fd(pipe);
|
if (*pipe) {
|
||||||
|
close_fd(pipe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process_arglist_free(&arglist);
|
process_arglist_free(&arglist);
|
||||||
|
|
Loading…
Reference in New Issue