From f4f73a8dfa26138c1726578262ea846e76533845 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 23 Nov 2013 15:04:35 +0000 Subject: [PATCH] Init vars in handle_cgi_request() --- build/src/cgi.c | 3 ++- mongoose.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/src/cgi.c b/build/src/cgi.c index 91304461..575eb704 100644 --- a/build/src/cgi.c +++ b/build/src/cgi.c @@ -235,7 +235,7 @@ static void prepare_cgi_environment(struct mg_connection *conn, } static void handle_cgi_request(struct mg_connection *conn, const char *prog) { - int headers_len, data_len, i, fdin[2], fdout[2]; + int headers_len, data_len, i, fdin[2] = {-1, -1}, fdout[2] = {-1, -1}; const char *status, *status_text; char buf[16384], *pbuf, dir[PATH_MAX], *p; struct mg_request_info ri; @@ -243,6 +243,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) { FILE *in = NULL, *out = NULL; pid_t pid = (pid_t) -1; + memset(&ri, 0, sizeof(ri)); prepare_cgi_environment(conn, prog, &blk); // CGI must be executed in its own directory. 'dir' must point to the diff --git a/mongoose.c b/mongoose.c index 82ca4065..a26c2c50 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3253,7 +3253,7 @@ static void prepare_cgi_environment(struct mg_connection *conn, } static void handle_cgi_request(struct mg_connection *conn, const char *prog) { - int headers_len, data_len, i, fdin[2], fdout[2]; + int headers_len, data_len, i, fdin[2] = {-1, -1}, fdout[2] = {-1, -1}; const char *status, *status_text; char buf[16384], *pbuf, dir[PATH_MAX], *p; struct mg_request_info ri; @@ -3261,6 +3261,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) { FILE *in = NULL, *out = NULL; pid_t pid = (pid_t) -1; + memset(&ri, 0, sizeof(ri)); prepare_cgi_environment(conn, prog, &blk); // CGI must be executed in its own directory. 'dir' must point to the