From 9b4a3ff6af6ce40a049d024ffa7db531f39a1fab Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Nov 2016 21:34:03 -0800 Subject: 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. --- lib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib.c') 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)) -- cgit v1.2.3