From dd7d0e4dcac46af6c692c10cbd7c66cbc1389828 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 20 Sep 2020 12:01:05 +0100 Subject: [PATCH] Robustify checking of shorthand-shorthands * src/lread.c (oblookup_considering_shorthand): Maybe warn when we find fishy shorthand-shorthands. --- src/lread.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lread.c b/src/lread.c index b3088c2af49..c6273263966 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4328,19 +4328,30 @@ oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff Lisp_Object oblookup_considering_shorthand (Lisp_Object obarray, Lisp_Object* string) { + Lisp_Object original = *string; /* Save pointer to original string... */ Lisp_Object tail = Vshorthand_shorthands; FOR_EACH_TAIL_SAFE(tail) { Lisp_Object pair = XCAR (tail); + if (!CONSP (pair)) goto undo; Lisp_Object shorthand = XCAR (pair); Lisp_Object longhand = XCDR (pair); - CHECK_STRING (shorthand); - CHECK_STRING (longhand); - Lisp_Object match = Fstring_match(shorthand, *string, Qnil); + if (!STRINGP (shorthand) || !STRINGP (longhand)) goto undo; + Lisp_Object match = Fstring_match (shorthand, *string, Qnil); if (!NILP(match)){ *string = Freplace_match(longhand, Qnil, Qnil, *string, Qnil); } } + goto fine; + undo: + { + static const char* warn = + "Fishy value of `shorthand-shorthands'. " + "Consider reviewing before evaluating code."; + message_dolog (warn, sizeof(warn), 0, 0); + *string = original; /* ...so we can any failed trickery here. */ + } + fine: return oblookup(obarray, SSDATA (*string), SCHARS (*string), SBYTES (*string)); } -- 2.39.5