From 216559a0a69b0df8bb91006b20051801a6c745ea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 20 Jul 2023 16:22:24 +0000 Subject: Make "cd" encoding-error-aware --- generic/tclCmdAH.c | 7 ++++++- unix/tclLoadDyld.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index c860004..31e3a96 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -283,7 +283,12 @@ Tcl_CdObjCmd( if (Tcl_FSConvertToPathType(interp, dir) != TCL_OK) { result = TCL_ERROR; } else { - result = Tcl_FSChdir(dir); + Tcl_DString ds; + result = Tcl_UtfToExternalDStringEx(NULL, NULL, TclGetString(dir), -1, 0, &ds, NULL); + Tcl_DStringFree(&ds); + if (result == TCL_OK) { + result = Tcl_FSChdir(dir); + } if (result != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't change working directory to \"%s\": %s", diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 0bb56c8..67e1682 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -189,7 +189,7 @@ TclpDlopen( Tcl_DStringFree(&ds); return TCL_ERROR; } - nativeFileName = Tcl_DStringValue(); + nativeFileName = Tcl_DStringValue(&ds); #if TCL_DYLD_USE_DLFCN /* @@ -347,7 +347,7 @@ FindSymbol( if (Tcl_UtfToExternalDStringEx(interp, NULL, symbol, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) { Tcl_DStringFree(&ds); - return TCL_ERROR; + return NULL; } native = Tcl_DStringValue(&ds); if (dyldLoadHandle->dlHandle) { -- cgit v0.12