summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorhobbs <hobbs>1999-10-13 00:32:49 (GMT)
committerhobbs <hobbs>1999-10-13 00:32:49 (GMT)
commit04ea820b91d40ed30eed4b56ad2f4a12a552cb3f (patch)
tree6644d69c8f99aa752688a9e211685986541523fb /unix
parent67604b787a8c97063919f609033bc87ac4d62995 (diff)
downloadtcl-04ea820b91d40ed30eed4b56ad2f4a12a552cb3f.zip
tcl-04ea820b91d40ed30eed4b56ad2f4a12a552cb3f.tar.gz
tcl-04ea820b91d40ed30eed4b56ad2f4a12a552cb3f.tar.bz2
* unix/Makefile.in: purify has to use -best-effort to instrument
* unix/tclAppInit.c: identified potential mem leak when compiling tcltest (not critical) * unix/tclUnixPipe.c: fixed mem leak in TclpCreateProcess when doing alloc between vfork and execvp. * unix/tclUnixTest.c: fixed mem leak in findexecutable test command
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in10
-rw-r--r--unix/tclAppInit.c5
-rw-r--r--unix/tclUnixInit.c4
-rw-r--r--unix/tclUnixPipe.c49
-rw-r--r--unix/tclUnixTest.c5
5 files changed, 43 insertions, 30 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index ab8b03f..a36f5bb 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.47 1999/09/21 06:37:29 hobbs Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.48 1999/10/13 00:32:49 hobbs Exp $
VERSION = @TCL_VERSION@
@@ -213,7 +213,7 @@ DLTEST_DIR = @TCL_SRC_DIR@/unix/dltest
# Must be absolute to so the corresponding tcltest's tcl_library is absolute.
TCL_BUILDTIME_LIBRARY= @TCL_SRC_DIR@/library
-#CC = purify @CC@
+#CC = purify -best-effort @CC@
CC = @CC@
#----------------------------------------------------------------
@@ -460,7 +460,7 @@ topDirName:
gendate:
yacc -l $(GENERIC_DIR)/tclGetDate.y
sed -e 's/yy/TclDate/g' -e '/^#include <values.h>/d' \
- -e 's/SCCSID/RCS: @(#) $$Id: Makefile.in,v 1.47 1999/09/21 06:37:29 hobbs Exp $$/' \
+ -e 's?SCCSID?RCS: @(#) $$Id: Makefile.in,v 1.48 1999/10/13 00:32:49 hobbs Exp $$?' \
-e '/#ifdef __STDC__/,/#endif/d' -e '/TclDateerrlab:/d' \
-e '/TclDatenewstate:/d' -e '/#pragma/d' \
-e '/#include <inttypes.h>/d' \
@@ -1064,8 +1064,8 @@ dist: $(UNIX_DIR)/configure
cp -p $(GENERIC_DIR)/*.decls $(DISTDIR)/generic
cp -p $(GENERIC_DIR)/README $(DISTDIR)/generic
cp -p $(GENERIC_DIR)/tclGetDate.y $(DISTDIR)/generic
- cp -p $(TOP_DIR)/changes $(TOP_DIR)/README* $(TOP_DIR)/license.terms \
- $(DISTDIR)
+ cp -p $(TOP_DIR)/changes $(TOP_DIR)/ChangeLog $(TOP_DIR)/README* \
+ $(TOP_DIR)/license.terms $(DISTDIR)
mkdir $(DISTDIR)/library
cp -p $(TOP_DIR)/license.terms $(TOP_DIR)/library/*.tcl \
$(TOP_DIR)/library/tclIndex $(DISTDIR)/library
diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c
index e452705..45d86eb 100644
--- a/unix/tclAppInit.c
+++ b/unix/tclAppInit.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclAppInit.c,v 1.6 1999/05/14 02:18:32 stanton Exp $
+ * RCS: @(#) $Id: tclAppInit.c,v 1.7 1999/10/13 00:32:49 hobbs Exp $
*/
#include "tcl.h"
@@ -69,6 +69,9 @@ main(argc, argv)
#ifdef TCL_TEST
/*
* Pass the build time location of the tcl library (to find init.tcl)
+ *
+ * This causes a 2400b "potential" mem leak, according to purify
+ * (the obj allocation that never seems to gets deallocated)
*/
Tcl_Obj *path;
path = Tcl_NewStringObj(TCL_BUILDTIME_LIBRARY, -1);
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index b0ca270..ca1d357 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclUnixInit.c,v 1.17 1999/07/22 21:50:56 redman Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.18 1999/10/13 00:32:49 hobbs Exp $
*/
#include "tclInt.h"
@@ -604,7 +604,7 @@ TclpSetVariables(interp)
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this
- * routine is case sensetive, on Windows this matches mioxed case.
+ * routine is case sensetive, on Windows this matches mixed case.
*
* Results:
* The return value is the index in environ of an entry with the
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index b78715c..f140555 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixPipe.c,v 1.3 1999/04/16 00:48:05 stanton Exp $
+ * RCS: @(#) $Id: tclUnixPipe.c,v 1.4 1999/10/13 00:32:50 hobbs Exp $
*/
#include "tclInt.h"
@@ -333,7 +333,9 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
TclFile errPipeIn, errPipeOut;
int joinThisError, count, status, fd;
char errSpace[200 + TCL_INTEGER_SPACE];
- int pid;
+ Tcl_DString *dsArray;
+ char **newArgv;
+ int pid, i;
errPipeIn = NULL;
errPipeOut = NULL;
@@ -350,13 +352,20 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
goto error;
}
+ /*
+ * We need to allocate and convert this before the (v)fork
+ * so it is properly deallocated later
+ */
+ dsArray = (Tcl_DString *) ckalloc(argc * sizeof(Tcl_DString));
+ newArgv = (char **) ckalloc((argc+1) * sizeof(char *));
+ newArgv[argc] = NULL;
+ for (i = 0; i < argc; i++) {
+ newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]);
+ }
+
joinThisError = (errorFile == outputFile);
pid = vfork();
if (pid == 0) {
- Tcl_DString *dsArray;
- char *oldArgv0;
- int i;
-
fd = GetFd(errPipeOut);
/*
@@ -370,8 +379,7 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
((dup2(1,2) == -1) ||
(fcntl(2, F_SETFD, 0) != 0)))) {
sprintf(errSpace,
- "%dforked process couldn't set up input/output: ",
- errno);
+ "%dforked process couldn't set up input/output: ", errno);
write(fd, errSpace, (size_t) strlen(errSpace));
_exit(1);
}
@@ -381,22 +389,21 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
*/
RestoreSignals();
- for (i = 0; argv[i] != NULL; i++) {
- /*
- * How many arguments?
- */
- }
- oldArgv0 = argv[0];
- dsArray = (Tcl_DString *) ckalloc(i * sizeof(Tcl_DString));
- for (i = 0; argv[i] != NULL; i++) {
- argv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]);
- }
- execvp(argv[0], argv); /* INTL: Native. */
- sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno,
- oldArgv0);
+ execvp(newArgv[0], newArgv); /* INTL: Native. */
+ sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno, argv[0]);
write(fd, errSpace, (size_t) strlen(errSpace));
_exit(1);
}
+
+ /*
+ * Free the mem we used for the fork
+ */
+ for (i = 0; i < argc; i++) {
+ Tcl_DStringFree(&dsArray[i]);
+ }
+ ckfree((char *) dsArray);
+ ckfree((char *) newArgv);
+
if (pid == -1) {
Tcl_AppendResult(interp, "couldn't fork child process: ",
Tcl_PosixError(interp), (char *) NULL);
diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c
index 7c7559b..d556a2b 100644
--- a/unix/tclUnixTest.c
+++ b/unix/tclUnixTest.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixTest.c,v 1.10 1999/04/16 00:48:05 stanton Exp $
+ * RCS: @(#) $Id: tclUnixTest.c,v 1.11 1999/10/13 00:32:50 hobbs Exp $
*/
#include "tclInt.h"
@@ -465,6 +465,9 @@ TestfindexecutableCmd(clientData, interp, argc, argv)
Tcl_SetResult(interp, tclExecutableName, TCL_VOLATILE);
ckfree(tclExecutableName);
}
+ if (tclNativeExecutableName != NULL) {
+ ckfree(tclNativeExecutableName);
+ }
tclExecutableName = oldName;
tclNativeExecutableName = oldNativeName;