summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2015-07-31 10:47:42 (GMT)
committersebres <sebres@users.sourceforge.net>2015-07-31 10:47:42 (GMT)
commitdbfc3509e51edf2537213ad9fb4ba3028fab3675 (patch)
treeef5e9a3561548dcb8e4810e4cf0f9f5b9f60cde7 /win/tclWinFile.c
parentec20498ab74fd4c48e24dcc7ecc9ff9e36b3ba72 (diff)
downloadtcl-sebres_clean_core_8_5.zip
tcl-sebres_clean_core_8_5.tar.gz
tcl-sebres_clean_core_8_5.tar.bz2
generic: reduced diffs to trunk, win: clean code after bug [f00009f7ce] was fixed in trunksebres_clean_core_8_5
Diffstat (limited to 'win/tclWinFile.c')
-rwxr-xr-xwin/tclWinFile.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index fe30c55..bffb343 100755
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -3171,7 +3171,7 @@ ClientData
TclNativeCreateNativeRep(
Tcl_Obj *pathPtr)
{
- char *nativePathPtr, *str;
+ char *nativePathPtr = NULL, *str;
Tcl_DString ds;
Tcl_Obj *validPathPtr;
int len;
@@ -3187,6 +3187,7 @@ TclNativeCreateNativeRep(
if (validPathPtr == NULL) {
return NULL;
}
+ /* refCount of validPathPtr was already incremented in Tcl_FSGetTranslatedPath */
} else {
/*
* Make sure the normalized path is set.
@@ -3196,6 +3197,7 @@ TclNativeCreateNativeRep(
if (validPathPtr == NULL) {
return NULL;
}
+ /* validPathPtr returned from Tcl_FSGetNormalizedPath is owned by Tcl, so incr refCount here */
Tcl_IncrRefCount(validPathPtr);
}
@@ -3228,9 +3230,7 @@ TclNativeCreateNativeRep(
}
while (len-->0) {
if ((*wp < ' ') || wcschr(L"\"*:<>?|", *wp)) {
- Tcl_DecrRefCount(validPathPtr);
- Tcl_DStringFree(&ds);
- return NULL;
+ goto done;
} else if (*wp=='/') {
*wp = '\\';
}
@@ -3261,9 +3261,7 @@ TclNativeCreateNativeRep(
}
while (len-->0) {
if ((*p < ' ') || strchr("\"*:<>?|", *p)) {
- Tcl_DecrRefCount(validPathPtr);
- Tcl_DStringFree(&ds);
- return NULL;
+ goto done;
} else if (*p=='/') {
*p = '\\';
}
@@ -3271,10 +3269,14 @@ TclNativeCreateNativeRep(
}
len = Tcl_DStringLength(&ds) + sizeof(char);
}
- Tcl_DecrRefCount(validPathPtr);
nativePathPtr = ckalloc((unsigned) len);
+ if (nativePathPtr == 0)
+ goto done;
memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len);
+ done:
+
+ Tcl_DecrRefCount(validPathPtr);
Tcl_DStringFree(&ds);
return (ClientData) nativePathPtr;
}