summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-11-01 07:44:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-11-01 07:44:22 -0700
commit0f482cf241584b58b7a9a8e97b32b7123b1cbe25 (patch)
treeac3b20868ba54388ac0a7f09cd200b27db4771b1 /lib.c
parentaf26ff8c2bc0741eaca3a3f3c59ddd60227f38a3 (diff)
downloadtxr-0f482cf241584b58b7a9a8e97b32b7123b1cbe25.tar.gz
txr-0f482cf241584b58b7a9a8e97b32b7123b1cbe25.tar.bz2
txr-0f482cf241584b58b7a9a8e97b32b7123b1cbe25.zip
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.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c7
1 files changed, 3 insertions, 4 deletions
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);