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
commit9b4a3ff6af6ce40a049d024ffa7db531f39a1fab (patch)
tree4c91ae468d6a03bb24848106e2991767eefff6c3
parent7c2b95c04cd3a0f566d076fa1ac2d8d93721b2ec (diff)
downloadtxr-9b4a3ff6af6ce40a049d024ffa7db531f39a1fab.tar.gz
txr-9b4a3ff6af6ce40a049d024ffa7db531f39a1fab.tar.bz2
txr-9b4a3ff6af6ce40a049d024ffa7db531f39a1fab.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))