summaryrefslogtreecommitdiffstats
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
commit77541ce87aa9bf6ce577a265f3e86539559f1eef (patch)
treeac3b20868ba54388ac0a7f09cd200b27db4771b1
parent9e11ad9e104b4c4c068cecdaca7838ce0a5cb055 (diff)
downloadtxr-77541ce87aa9bf6ce577a265f3e86539559f1eef.tar.gz
txr-77541ce87aa9bf6ce577a265f3e86539559f1eef.tar.bz2
txr-77541ce87aa9bf6ce577a265f3e86539559f1eef.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.
-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);