From 486b74f728fb7496af65cb401e5624cefbe816a8 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 4 Jul 2023 11:45:27 +0200 Subject: [PATCH] Prevent a crash if p==NULL (due to buggy input) --- src/spicelib/parser/inpptree.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spicelib/parser/inpptree.c b/src/spicelib/parser/inpptree.c index 398771048..063bbd5f9 100644 --- a/src/spicelib/parser/inpptree.c +++ b/src/spicelib/parser/inpptree.c @@ -1167,12 +1167,20 @@ INPparseNode *PT_mkfnode(const char *fname, INPparseNode * arg) p->function = funcs[i].funcptr; p->data = NULL; - if(p->funcnum == PTF_PWL) + if (p->funcnum == PTF_PWL) { p = prepare_PTF_PWL(p); + if (p == NULL) { + fprintf(stderr, "Error while parsing function '%s'\n", buf); + if (ft_stricterror) + controlled_exit(EXIT_BAD); + return mkfirst(NULL, arg); + } + } if (p->funcnum == PTF_DDT) p = prepare_PTF_DDT(p); + return (p); }