From 41e5d02edbc6a43dc07f0e0e86825ce9f7f84ec9 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sat, 24 Oct 2020 03:15:08 +0200 Subject: [PATCH] error check for strrchr() NULL return value in print_spice_element() --- src/token.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/token.c b/src/token.c index f86e2d0c..b74c8459 100644 --- a/src/token.c +++ b/src/token.c @@ -1658,7 +1658,8 @@ void print_spice_element(FILE *fd, int inst) } /* do a second round of substitutions, but without calling tcl */ if(result && strstr(result, "eval(") == result) { - strrchr(result, ')')[0]= '\0'; + char *c = strrchr(result, ')'); + if(c) *c = '\0'; my_strdup2(88, &result, translate(inst, result+5)); } fprintf(fd, "%s", result);