summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDl.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-07 13:14:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-07 13:14:27 (GMT)
commit81cbdd313896511542f19465bf012631591474db (patch)
treec49dc1fe97fe4e01700df537d02c148d31f918f3 /unix/tclLoadDl.c
parent236c0f4ffd3ac7f1cef522c0c0e00b9e72cf995f (diff)
downloadtcl-81cbdd313896511542f19465bf012631591474db.zip
tcl-81cbdd313896511542f19465bf012631591474db.tar.gz
tcl-81cbdd313896511542f19465bf012631591474db.tar.bz2
Where "interp" is only used for error-reporting, it can be allowed to be NULL. This should fix [5da26d4760]: Tcl_LoadFile() segfaults if "interp" is NULL.
Diffstat (limited to 'unix/tclLoadDl.c')
-rw-r--r--unix/tclLoadDl.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c
index dc711f8..aec071c 100644
--- a/unix/tclLoadDl.c
+++ b/unix/tclLoadDl.c
@@ -124,9 +124,11 @@ TclpDlopen(
const char *errorStr = dlerror();
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "couldn't load file \"%s\": %s",
- Tcl_GetString(pathPtr), errorStr));
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't load file \"%s\": %s",
+ Tcl_GetString(pathPtr), errorStr));
+ }
return TCL_ERROR;
}
newHandle = ckalloc(sizeof(*newHandle));
@@ -187,17 +189,18 @@ FindSymbol(
Tcl_DStringFree(&newName);
}
Tcl_DStringFree(&ds);
- if (proc == NULL && interp != NULL) {
+ if (proc == NULL) {
const char *errorStr = dlerror();
- if (!errorStr) {
- errorStr = "unknown";
+ if (interp) {
+ if (!errorStr) {
+ errorStr = "unknown";
+ }
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "cannot find symbol \"%s\": %s", symbol, errorStr));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol,
+ NULL);
}
-
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "cannot find symbol \"%s\": %s", symbol, errorStr));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol,
- NULL);
}
return proc;
}