From 0f482cf241584b58b7a9a8e97b32b7123b1cbe25 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 1 Nov 2021 07:44:22 -0700 Subject: less: symbolic arguments: fix crash and incorrectness. * lib.c (less): We cannot direclty access right->s.package because the right operand can be nil. This causes a crash. Furthermore, the separate NIL case is wrong. If the left object is nil, the same logic must be carried out as for SYM. The opposite operand might have the same name, and so packages have to be compared. We simply merge the two cases, and make sure we use the proper accessors symbol_name and symbol_package to avoid blowing up on nil. --- lib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 6b13be82..0fdc8ef0 100644 --- a/lib.c +++ b/lib.c @@ -6227,17 +6227,16 @@ tail: case LSTR: return str_lt(left, right); case NIL: - return str_lt(nil_string, symbol_name(right)); case SYM: { - val cmp = cmp_str(left->s.name, symbol_name(right)); + val cmp = cmp_str(symbol_name(left), symbol_name(right)); if (cmp == negone) { return t; } else if (cmp == one) { return nil; } else { - val lpkg = left->s.package; - val rpkg = right->s.package; + val lpkg = symbol_package(left); + val rpkg = symbol_package(right); if (lpkg == nil && rpkg == nil) return tnil(left < right); -- cgit v1.2.3