diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-10 21:34:03 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-10 21:34:03 -0800 |
commit | e2551ec31d9de4ce5b2debfab66486ca55c2cdd8 (patch) | |
tree | 4c91ae468d6a03bb24848106e2991767eefff6c3 | |
parent | 3637edad5a385ae252880a0085aa3c62f1a27675 (diff) | |
download | txr-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.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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)) |