From a14217b8a4e507a7f75ccc8aa587a44ef0df2414 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 8 Nov 2016 21:33:48 -0800 Subject: Check that name is stringp in some sym functions. * lib.c (make_sym, make_package, intern): Check that the name argument is a string. --- lib.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib.c b/lib.c index 21901c7f..525b5bbf 100644 --- a/lib.c +++ b/lib.c @@ -4752,12 +4752,16 @@ val symbol_package(val sym) val make_sym(val name) { - val obj = make_obj(); - obj->s.type = SYM; - obj->s.name = name; - obj->s.package = nil; - obj->s.slot_cache = 0; - return obj; + if (t && !stringp(name)) { + uw_throwf(error_s, lit("make-sym: name ~s isn't a string"), name, nao); + } else { + val obj = make_obj(); + obj->s.type = SYM; + obj->s.name = name; + obj->s.package = nil; + obj->s.slot_cache = 0; + return obj; + } } val gensym(val prefix) @@ -4773,6 +4777,11 @@ val make_package(val name) { if (find_package(name)) { uw_throwf(error_s, lit("make-package: ~s exists already"), name, nao); + } else if (t && !stringp(name)) { + uw_throwf(error_s, lit("make-package: name ~s isn't a string"), name, nao); + } else if (length(name) == zero) { + uw_throwf(error_s, lit("make-package: package name can't be empty string"), + nao); } else { val obj = make_obj(); obj->pk.type = PKG; @@ -4831,6 +4840,9 @@ val intern(val str, val package) val new_p; loc place; + if (!stringp(str)) + uw_throwf(error_s, lit("intern: name ~s isn't a string"), str, nao); + if (null_or_missing_p(package)) { package = cur_package; } else if (stringp(package)) { -- cgit v1.2.3