summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-10 21:34:03 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-10 21:34:03 -0800
commite2551ec31d9de4ce5b2debfab66486ca55c2cdd8 (patch)
tree4c91ae468d6a03bb24848106e2991767eefff6c3
parent3637edad5a385ae252880a0085aa3c62f1a27675 (diff)
downloadtxr-e2551ec31d9de4ce5b2debfab66486ca55c2cdd8.tar.gz
txr-e2551ec31d9de4ce5b2debfab66486ca55c2cdd8.tar.bz2
txr-e2551ec31d9de4ce5b2debfab66486ca55c2cdd8.zip
Check for non-package value in *package*.
* lib.c (get_current_package): If *package* contains nonsense, then reset it to a sane value and throw an exception.
-rw-r--r--lib.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index aea94320..aee22096 100644
--- a/lib.c
+++ b/lib.c
@@ -5107,7 +5107,15 @@ val keywordp(val sym)
val get_current_package(void)
{
- return cdr(lookup_var(nil, package_s));
+ val pkg_binding = lookup_var(nil, package_s);
+ val pkg = cdr(pkg_binding);
+ if (type(pkg) != PKG) {
+ rplacd(pkg_binding, user_package);
+ uw_throwf(error_s, lit("variable *package* non-package "
+ "value ~s (reset to sane value)"),
+ pkg, nao);
+ }
+ return pkg;
}
val func_f0(val env, val (*fun)(val))