aboutsummaryrefslogtreecommitdiffstats
path: root/local.c
diff options
context:
space:
mode:
authorAIDA Shinra <shinra@j10n.org>2013-10-14 13:31:01 +0000
committerTatsuya Kinoshita <tats@debian.org>2013-10-14 13:31:01 +0000
commitec81194f386f35b0d914e0fc5c727cd217c62c91 (patch)
tree1a64910741c607abe7d19b92bdfa34f3506507ae /local.c
parentMerge from upstream on 2012-05-22 (diff)
downloadw3m-ec81194f386f35b0d914e0fc5c727cd217c62c91.tar.gz
w3m-ec81194f386f35b0d914e0fc5c727cd217c62c91.zip
Workaround of GC crash on Cygwin64
Patch from <http://www.j10n.org/files/w3m-cvs-1.1055-win64gc.patch>, [w3m-dev:04469] on 2013-10-14.
Diffstat (limited to 'local.c')
-rw-r--r--local.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/local.c b/local.c
index f5a73a2..959bd66 100644
--- a/local.c
+++ b/local.c
@@ -359,6 +359,10 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
int status;
pid_t pid;
char *file = uri, *name = uri, *path_info = NULL, *tmpf = NULL;
+#ifdef HAVE_CHDIR
+ char *cgi_dir;
+#endif
+ char *cgi_basename;
#ifdef __MINGW32_VERSION
return NULL;
@@ -373,7 +377,14 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
if (!fw)
return NULL;
}
+ if (qstr)
+ uri = Strnew_m_charp(uri, "?", qstr, NULL)->ptr;
+#ifdef HAVE_CHDIR
+ cgi_dir = mydirname(file);
+#endif
+ cgi_basename = mybasename(file);
pid = open_pipe_rw(&fr, NULL);
+ /* Don't invoke gc after here, or the program might crash in some platforms */
if (pid < 0)
return NULL;
else if (pid) {
@@ -383,8 +394,6 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
}
setup_child(TRUE, 2, fw ? fileno(fw) : -1);
- if (qstr)
- uri = Strnew_m_charp(uri, "?", qstr, NULL)->ptr;
set_cgi_environ(name, file, uri);
if (path_info)
set_environ("PATH_INFO", path_info);
@@ -415,11 +424,11 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
}
#ifdef HAVE_CHDIR /* ifndef __EMX__ ? */
- chdir(mydirname(file));
+ chdir(cgi_dir);
#endif
- execl(file, mybasename(file), NULL);
+ execl(file, cgi_basename, NULL);
fprintf(stderr, "execl(\"%s\", \"%s\", NULL): %s\n",
- file, mybasename(file), strerror(errno));
+ file, cgi_basename, strerror(errno));
exit(1);
return NULL;
#endif